Bläddra i källkod

allow using Dynamic as `@:generic` type parameter

Simon Krajewski 10 år sedan
förälder
incheckning
3c81543400
2 ändrade filer med 18 tillägg och 0 borttagningar
  1. 1 0
      codegen.ml
  2. 17 0
      tests/unit/src/unit/issues/Issue4273.hx

+ 1 - 0
codegen.ml

@@ -247,6 +247,7 @@ let make_generic ctx ps pt p =
 				| TAbstract(a,tl) -> (s_type_path_underscore a.a_path) ^ (loop_tl tl)
 				| _ when not top -> "_" (* allow unknown/incompatible types as type parameters to retain old behavior *)
 				| TMono _ -> raise (Generic_Exception (("Could not determine type for parameter " ^ s), p))
+				| TDynamic _ -> "Dynamic"
 				| t -> raise (Generic_Exception (("Type parameter must be a class or enum instance (found " ^ (s_type (print_context()) t) ^ ")"), p))
 			and loop_tl tl = match tl with
 				| [] -> ""

+ 17 - 0
tests/unit/src/unit/issues/Issue4273.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+@:generic
+private class Value<T> {
+    public var v :T;
+
+    public function new (v :T) {
+        this.v = v;
+    }
+}
+
+class Issue4273 extends Test {
+	function test() {
+		var anything = new Value<Dynamic>(666);
+		eq(666, anything.v);
+	}
+}