Ver código fonte

[typer] don't allow transitive casts on static extensions

closes #9417
Simon Krajewski 5 anos atrás
pai
commit
6bd67f8c9a

+ 1 - 1
src/typing/typerBase.ml

@@ -200,7 +200,7 @@ let unify_static_extension ctx e t p =
 	if multitype_involed e.etype t then
 		AbstractCast.cast_or_unify_raise ctx t e p
 	else begin
-		Type.unify e.etype t;
+		Type.unify_custom {default_unification_context with allow_transitive_cast = false} e.etype t;
 		e
 	end
 

+ 14 - 0
tests/misc/projects/Issue9417/Main.hx

@@ -0,0 +1,14 @@
+using Main.Ext;
+
+abstract D(Dynamic) to Dynamic {}
+
+class Ext {
+	public static function round(f:Float) {}
+}
+
+class Main {
+	static function main() {
+		var d:D = null;
+		d.round();
+	}
+}

+ 1 - 0
tests/misc/projects/Issue9417/compile-fail.hxml

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

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

@@ -0,0 +1 @@
+Main.hx:12: characters 5-10 : D has no field round