Quellcode durchsuchen

override follow in genswf to deal with TAbstract (closes #3178)

Simon Krajewski vor 11 Jahren
Ursprung
Commit
578ae8f016
2 geänderte Dateien mit 29 neuen und 0 gelöschten Zeilen
  1. 6 0
      genswf9.ml
  2. 23 0
      tests/unit/issues/Issue3178.hx

+ 6 - 0
genswf9.ml

@@ -104,6 +104,12 @@ type context = {
 	mutable for_call : bool;
 }
 
+let rec follow t = match Type.follow t with
+	| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
+		follow (Codegen.Abstract.get_underlying_type a tl)
+	| t ->
+		t
+
 let invalid_expr p = error "Invalid expression" p
 let stack_error p = error "Stack error" p
 

+ 23 - 0
tests/unit/issues/Issue3178.hx

@@ -0,0 +1,23 @@
+package unit.issues;
+
+private abstract A(String) {
+	public inline function new(s : String) {
+		this = s;
+	}
+
+	public function f(index : Int) {
+		return StringTools.fastCodeAt(this, index);
+	}
+
+	public inline function g(index : Int) {
+		return StringTools.fastCodeAt(this, index);
+	}
+}
+
+class Issue3178 extends unit.Test {
+	function test() {
+		var a = new A("a");
+		eq(97, a.f(0));
+		eq(97, a.g(0));
+	}
+}