소스 검색

build a class before unification with an anon (#9794)

Aleksandr Kuzmenko 5 년 전
부모
커밋
ab89c78e04
3개의 변경된 파일34개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      src/core/tUnification.ml
  2. 32 0
      tests/misc/projects/Issue9769/Main.hx
  3. 1 0
      tests/misc/projects/Issue9769/compile.hxml

+ 1 - 0
src/core/tUnification.ml

@@ -680,6 +680,7 @@ let rec unify (uctx : unification_context) a b =
 				(* one of the constraints must unify with { } *)
 				if not (List.exists (fun t -> match follow t with TInst _ | TAnon _ -> true | _ -> false) pl) then error [cannot_unify a b]
 			| _ -> ());
+		ignore(c.cl_build());
 		(try
 			PMap.iter (fun n f2 ->
 				(*

+ 32 - 0
tests/misc/projects/Issue9769/Main.hx

@@ -0,0 +1,32 @@
+#if macro
+import haxe.macro.Context;
+#end
+
+#if !macro
+class Main {
+	public static function main() {
+		final array:MyArray<String> = ["hello", "world"];
+	}
+}
+#end
+
+#if !macro
+@:build(MyMacro.build())
+#end
+abstract MyArray<T>(Array<T>) from Array<T> to Iterable<T> {}
+
+class MyMacro {
+	#if macro
+	static function build() {
+		switch (Context.getLocalType()) {
+			case TInst(_.get() => type, _):
+				switch (type.kind) {
+					case KAbstractImpl(_.get() => abstractType):
+					default:
+				}
+			default:
+		}
+		return null;
+	}
+	#end
+}

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

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