瀏覽代碼

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

Simon Krajewski 11 年之前
父節點
當前提交
578ae8f016
共有 2 個文件被更改,包括 29 次插入0 次删除
  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));
+	}
+}