Переглянути джерело

`--macro nullSafety("my.pack")`

Alexander Kuzmenko 6 роки тому
батько
коміт
a193d957fb
2 змінених файлів з 12 додано та 1 видалено
  1. 11 0
      std/haxe/macro/Compiler.hx
  2. 1 1
      tests/nullsafety/test.hxml

+ 11 - 0
std/haxe/macro/Compiler.hx

@@ -385,6 +385,17 @@ class Compiler {
 		}
 	}
 
+	/**
+		Enables null safety for a type or a package.
+
+		@param path A package, module or sub-type dot path to keep.
+		@param paths An Array of package, module or sub-type dot paths to keep.
+		@param recursive If true, recurses into sub-packages for package paths.
+	**/
+	public static function nullSafety(path : String, ?recursive:Bool = true) {
+		addGlobalMetadata(path, "@:nullSafety", recursive);
+	}
+
 	/**
 		Adds metadata `meta` to all types (if `toTypes = true`) or fields (if
 		`toFields = true`) whose dot-path matches `pathFilter`.

+ 1 - 1
tests/nullsafety/test.hxml

@@ -2,5 +2,5 @@
 -main cases.Test
 -D analyzer-optimize
 
---macro addGlobalMetadata('cases', '@:nullSafety')
+--macro nullSafety('cases')
 --macro Validator.register()