Bläddra i källkod

[cs] Constants are never Null<> - fixed constants' mistype on constructors with constant parameters. Closes #3138

Cauê Waneck 11 år sedan
förälder
incheckning
55cccede71
2 ändrade filer med 37 tillägg och 1 borttagningar
  1. 1 1
      gencommon.ml
  2. 36 0
      tests/unit/issues/Issue3138.hx

+ 1 - 1
gencommon.ml

@@ -10056,7 +10056,7 @@ struct
 												| Some o -> o
 												| Some o -> o
 											in
 											in
 											let e = { e with eexpr = TLocal v2; etype = basic.tnull e.etype } in
 											let e = { e with eexpr = TLocal v2; etype = basic.tnull e.etype } in
-											let const = mk_cast e.etype { e with eexpr = TConst(o); etype = v.v_type } in
+											let const = mk_cast e.etype { e with eexpr = TConst(o); etype = follow v.v_type } in
 											found := true;
 											found := true;
 											{ e with eexpr = TIf({
 											{ e with eexpr = TIf({
 												eexpr = TBinop(Ast.OpEq, e, null e.etype e.epos);
 												eexpr = TBinop(Ast.OpEq, e, null e.etype e.epos);

+ 36 - 0
tests/unit/issues/Issue3138.hx

@@ -0,0 +1,36 @@
+package unit.issues;
+
+class Issue3138 extends Test
+{
+	public function test()
+	{
+		var a = new B();
+#if (java || cs)
+		var b = new D();
+#end
+	}
+}
+
+private class A {
+    public function new(a) {}
+}
+
+private class B extends A {
+    public function new(?a = 1) {
+        super(a); // error CS0030: Cannot convert type 'int' to 'haxe.lang.Null<int>'
+    }
+}
+
+#if (cs || java)
+
+private class C {
+    public function new(a) {}
+}
+
+private class D extends C {
+    public function new(?a:Single = 1) {
+        super(a); // error CS0030: Cannot convert type 'int' to 'haxe.lang.Null<int>'
+    }
+}
+
+#end