Parcourir la source

Change Map.toStringMap, so T:String takes precedence over {} and StringMap is used over ObjectMap (closes #3777)

Dan Korostelev il y a 10 ans
Parent
commit
7bd20953e8
2 fichiers modifiés avec 18 ajouts et 1 suppressions
  1. 1 1
      std/Map.hx
  2. 17 0
      tests/unit/src/unit/issues/Issue3777.hx

+ 1 - 1
std/Map.hx

@@ -134,7 +134,7 @@ abstract Map<K,V>(IMap<K,V> ) {
 		return v;
 	}
 
-	@:to static inline function toStringMap<V>(t:IMap<String,V>):StringMap<V> {
+	@:to static inline function toStringMap<K:String,V>(t:IMap<K,V>):StringMap<V> {
 		return new StringMap<V>();
 	}
 

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

@@ -0,0 +1,17 @@
+package unit.issues;
+
+private class A<T:String> {
+    public function new() f();
+    function f():Map<T,Int> throw "not implemented";
+}
+
+private class B extends A<String> {
+    override function f() return ["a" => 1];
+}
+
+class Issue3777 extends unit.Test {
+    function test() {
+        // if it compiles, it works
+        new B();
+    }
+}