Selaa lähdekoodia

[display] don't overwrite static extensions

closes #8584
Simon Krajewski 6 vuotta sitten
vanhempi
commit
1b9dfa0dc6

+ 1 - 1
src/context/display/displayFields.ml

@@ -50,7 +50,7 @@ let collect_static_extensions ctx items e p =
 		| (c,_) :: l ->
 			let rec dup t = Type.map dup t in
 			let acc = List.fold_left (fun acc f ->
-				if Meta.has Meta.NoUsing f.cf_meta || Meta.has Meta.NoCompletion f.cf_meta || Meta.has Meta.Impl f.cf_meta || PMap.mem f.cf_name items then
+				if Meta.has Meta.NoUsing f.cf_meta || Meta.has Meta.NoCompletion f.cf_meta || Meta.has Meta.Impl f.cf_meta || PMap.mem f.cf_name acc then
 					acc
 				else begin
 					let f = { f with cf_type = opt_type f.cf_type } in

+ 23 - 0
tests/display/src/cases/StaticExtension.hx

@@ -44,4 +44,27 @@ class StaticExtension extends DisplayTestCase {
 		eq(true, hasField(fields, "doSomething", "Void -> Void"));
 		eq(true, hasField(fields, "doSomethingElse", "Void -> Void"));
 	}
+
+	/**
+		using cases.StaticExtension;
+
+		class Overload1 {
+			public static function test(o:String):Void { }
+		}
+
+		class Overload2 {
+			public static function test(o:String, i:Int):Void { }
+		}
+
+		class Main {
+			static public function main() {
+				"".{-1-}
+			}
+		}
+	**/
+	function testIssue8584() {
+		var fields = fields(pos(1));
+		eq(true, hasField(fields, "test", "(i : Int) -> Void"));
+		eq(false, hasField(fields, "test", "() -> Void"));
+	}
 }