Procházet zdrojové kódy

preserve constructor argument names in `Cls.new` functions

Dan Korostelev před 8 roky
rodič
revize
ffda2f576f
2 změnil soubory, kde provedl 13 přidání a 1 odebrání
  1. 1 1
      src/typing/typer.ml
  2. 12 0
      tests/display/src/cases/Basic.hx

+ 1 - 1
src/typing/typer.ml

@@ -2628,7 +2628,7 @@ and type_access ctx e p mode =
 					tf_args = List.map (fun v -> v,None) vl;
 					tf_type = t;
 					tf_expr = mk (TReturn (Some ec)) t p;
-				}) (tfun (List.map (fun v -> v.v_type) vl) t) p)
+				}) (TFun ((List.map (fun v -> v.v_name,false,v.v_type) vl),t)) p)
 			| _ -> error "Binding new is only allowed on class types" p
 		end;
 	| EField _ ->

+ 12 - 0
tests/display/src/cases/Basic.hx

@@ -85,4 +85,16 @@ class Basic extends DisplayTestCase {
 	@:funcCode function testMissingParams() {
 		eq("Array<Array.T>", type(pos(1)));
 	}
+
+	/**
+	class Some {
+		function new(someName:Int) {}
+		function main() {
+			Some.new{-1-}
+		}
+	}
+	**/
+	function testCtorClosureType() {
+		eq("someName : Int -> cases.Some", type(pos(1)));
+	}
 }