فهرست منبع

Revert "[typer] allow `@:const` type parameters instead of consts too"

This reverts commit 8729bd3f2b636f18c1a79fab420a0072c1565562.

closes #7476
closes #7479
see #7291
Simon Krajewski 7 سال پیش
والد
کامیت
ac2fbaddb2
2فایلهای تغییر یافته به همراه17 افزوده شده و 6 حذف شده
  1. 2 6
      src/typing/typeload.ml
  2. 15 0
      tests/unit/src/unit/issues/Issue7476.hx

+ 2 - 6
src/typing/typeload.ml

@@ -299,17 +299,13 @@ let rec load_instance' ctx (t,p) allow_no_params =
 			let rec loop tl1 tl2 is_rest = match tl1,tl2 with
 				| t :: tl1,(name,t2) :: tl2 ->
 					let check_const c =
-						let is_expression,is_const = match follow t with
-							| TInst ({ cl_kind = KExpr _ },_) -> true,false
-							| TInst ({ cl_kind = KTypeParameter _ } as c,_) -> false,Meta.has Meta.Const c.cl_meta
-							| _ -> false,false
-						in
+						let is_expression = (match t with TInst ({ cl_kind = KExpr _ },_) -> true | _ -> false) in
 						let expects_expression = name = "Const" || Meta.has Meta.Const c.cl_meta in
 						let accepts_expression = name = "Rest" in
 						if is_expression then begin
 							if not expects_expression && not accepts_expression then
 								error "Constant value unexpected here" p
-						end else if expects_expression && not is_const then
+						end else if expects_expression then
 							error "Type parameter is expected to be a constant value" p
 					in
 					let is_rest = is_rest || name = "Rest" && is_generic_build in

+ 15 - 0
tests/unit/src/unit/issues/Issue7476.hx

@@ -0,0 +1,15 @@
+package unit.issues;
+
+class Issue7476 extends unit.Test {
+	function test() {
+
+	}
+}
+
+private typedef FooBar = {
+	var foo:Array<Foo & Bar>;
+}
+
+private typedef Foo = {}
+
+private typedef Bar = {}