Browse Source

don't build `@:generic` types in display mode (closes #5134)

Simon Krajewski 9 years ago
parent
commit
3dec4117b1

+ 1 - 1
src/typing/typeload.ml

@@ -3778,7 +3778,7 @@ let rec build_generic ctx c p tl =
 			()
 			()
 	in
 	in
 	List.iter check_recursive tl;
 	List.iter check_recursive tl;
-	if !recurse then begin
+	if !recurse || ctx.com.display <> DMNone then begin
 		TInst (c,tl) (* build a normal instance *)
 		TInst (c,tl) (* build a normal instance *)
 	end else begin
 	end else begin
 	let gctx = make_generic ctx c.cl_params tl p in
 	let gctx = make_generic ctx c.cl_params tl p in

+ 23 - 0
tests/misc/projects/Issue5134/Main.hx

@@ -0,0 +1,23 @@
+@:generic
+class A<T> {
+    var items:Array<T>;
+    public function new() {
+        items = [];
+    }
+    inline public function get(_index:Int) : T {
+        return items[_index];
+    }
+}
+
+class Test {
+
+    var a: A<Int>;
+
+    function new() {
+
+    }
+    static function main() {
+        trace("Haxe is great!");
+        a.
+    }
+}

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

@@ -0,0 +1 @@
+--display Main.hx@323

+ 2 - 0
tests/misc/projects/Issue5134/compile-fail.hxml.stderr

@@ -0,0 +1,2 @@
+Main.hx:21: characters 8-9 : Cannot access a in static function
+Main.hx:12: characters 0-5 : Defined in this class