浏览代码

Flush PBuildClass on macro.Context.getType() (#8410)

* flush PBuildClass on macro.Context.getType()

* don't flush everything; just built the requested class

* this is the place

* this one

* Don't flush everything, just built requestd class/abstract

* cleanup [skip ci]
Aleksandr Kuzmenko 6 年之前
父节点
当前提交
e258b49dde

+ 5 - 1
src/typing/instanceBuilder.ml

@@ -74,7 +74,11 @@ let build_instance ctx mtype p =
 				let tf = (f()) in
 				unify_raise ctx tf t p;
 				link_dynamic t tf;
-				if ctx.pass >= PBuildClass then flush_pass ctx PBuildClass "after_build_instance";
+				(match tf with
+					| TInst (c, _) -> ignore(c.cl_build())
+					| TAbstract (a, _) -> Abstract.build_abstract a
+					| _ -> ()
+				);
 				t
 			) s in
 			TLazy r

+ 25 - 0
tests/misc/projects/Issue7905/Main.hx

@@ -0,0 +1,25 @@
+#if !macro
+typedef Huh = GenericBuild<Int>;
+@:genericBuild(Main.GenericBuild.build())
+#end
+class GenericBuild<T> {
+  #if macro
+  static var counter = 0;
+  static function build() {
+    var name = 'Cls${counter++}';
+    var ret = macro class $name {
+      public function new() {}
+    }
+    haxe.macro.Context.defineType(ret);
+    return haxe.macro.Context.getType(name);
+  }
+  #end
+}
+
+class Main {
+  static function main() {
+    #if !macro
+    $type(Huh.new);
+    #end
+  }
+}

+ 1 - 0
tests/misc/projects/Issue7905/compile.hxml

@@ -0,0 +1 @@
+-main Main

+ 1 - 0
tests/misc/projects/Issue7905/compile.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:22: characters 11-18 : Warning : Void -> Cls0