Просмотр исходного кода

do not cast with @:to functions of multi-type abstracts

Simon Krajewski 12 лет назад
Родитель
Сommit
6261b9476e
2 измененных файлов с 9 добавлено и 2 удалено
  1. 4 2
      codegen.ml
  2. 5 0
      std/Map.hx

+ 4 - 2
codegen.ml

@@ -1340,17 +1340,19 @@ let handle_abstract_casts ctx e =
 					eright
 				else begin
 					let c,cfo,a,pl = try
+						if Meta.has Meta.MultiType a1.a_meta then raise Not_found;
 						c1,snd (find_abstract_to a1 pl1 t2),a1,pl1
 					with Not_found ->
+						if Meta.has Meta.MultiType a2.a_meta then raise Not_found;
 						c2,snd (find_from a2 pl2 t1 t2),a2,pl2
 					in
 					match cfo with None -> eright | Some cf -> make_static_call c cf a pl [eright] tleft p
 				end
 			| TDynamic _,_ | _,TDynamic _ ->
 				eright
-			| TAbstract({a_impl = Some c} as a,pl),t2 ->
+			| TAbstract({a_impl = Some c} as a,pl),t2 when not (Meta.has Meta.MultiType a.a_meta) ->
 				begin match snd (find_abstract_to a pl t2) with None -> eright | Some cf -> make_static_call c cf a pl [eright] tleft p end
-			| t1,(TAbstract({a_impl = Some c} as a,pl) as t2) ->
+			| t1,(TAbstract({a_impl = Some c} as a,pl) as t2) when not (Meta.has Meta.MultiType a.a_meta) ->
 				begin match snd (find_from a pl t1 t2) with None -> eright | Some cf -> make_static_call c cf a pl [eright] tleft p end
 			| _ ->
 				eright)

+ 5 - 0
std/Map.hx

@@ -72,6 +72,11 @@ abstract Map< K, V > (IMap< K, V > ) {
 		
 		If no such mapping exists, null is returned.
 		
+		Note that a check like map.get(key) == null can hold for two reasons:
+			1. the map has no mapping for [key]
+			2. the map has a mapping with a value of null
+		If it is important to distinguish these cases, exists() should be used.
+		
 		If [key] is null, the result is unspecified.
 	**/
 	public inline function get(key:K) return this.get(key)