Browse Source

re-unify upon reapplying overloaded calls (fixes #9854)

Aleksandr Kuzmenko 4 years ago
parent
commit
d764121f23

+ 4 - 1
src/typing/callUnification.ml

@@ -600,7 +600,10 @@ let maybe_reapply_overload_call ctx e =
 			let recall fh cf =
 				let fa = FieldAccess.create e1 cf fh false ef.epos in
 				let fcc = unify_field_call ctx fa el [] e.epos false in
-				fcc.fc_data()
+				let e1 = fcc.fc_data() in
+				(try Type.unify e1.etype e.etype
+				with Unify_error _ -> die ~p:e.epos "Failed to reapply overload call" __LOC__);
+				e1
 			in
 			begin match fa with
 			| FStatic(c,cf) when has_class_field_flag cf CfOverload ->

+ 15 - 0
tests/misc/projects/Issue9854/Main.hx

@@ -0,0 +1,15 @@
+class Main {
+	overload
+	static function infer<T>(s:String):T {
+		return null;
+	}
+
+	static inline function inlineMe():String {
+		return infer("foo");
+	}
+
+	static function main() {
+		var x = inlineMe();
+		$type(x); // Unknown<0>
+	}
+}

+ 2 - 0
tests/misc/projects/Issue9854/compile.hxml

@@ -0,0 +1,2 @@
+--main Main
+--jvm bin/test.jar

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

@@ -0,0 +1 @@
+Main.hx:13: characters 9-10 : Warning : String