Selaa lähdekoodia

add temp fix for #4843

Simon Krajewski 9 vuotta sitten
vanhempi
commit
49ac2695f7
2 muutettua tiedostoa jossa 17 lisäystä ja 4 poistoa
  1. 13 0
      tests/unit/src/unit/issues/Issue4843.hx
  2. 4 4
      typer.ml

+ 13 - 0
tests/unit/src/unit/issues/Issue4843.hx

@@ -0,0 +1,13 @@
+package unit.issues;
+
+private abstract A({}) from {} {
+	@:from static function fromB(b:{a:Int}):A {
+		return null;
+	}
+}
+
+class Issue4843 extends Test {
+	function test() {
+		var a:A = {};
+	}
+}

+ 4 - 4
typer.ml

@@ -3007,11 +3007,11 @@ and type_object_decl ctx fl with_type p =
 	let dynamic_parameter = ref None in
 	let a = (match with_type with
 	| WithType t ->
-		let rec loop t =
+		let rec loop in_abstract_from t =
 			match follow t with
-			| TAnon a when not (PMap.is_empty a.a_fields) -> ODKWithStructure a
+			| TAnon a when not (PMap.is_empty a.a_fields) && not in_abstract_from -> ODKWithStructure a
 			| TAbstract (a,pl) when not (Meta.has Meta.CoreType a.a_meta) ->
-				(match List.fold_left (fun acc t -> match loop t with ODKPlain -> acc | t -> t :: acc) [] (get_abstract_froms a pl) with
+				(match List.fold_left (fun acc t -> match loop true t with ODKPlain -> acc | t -> t :: acc) [] (get_abstract_froms a pl) with
 				| [t] -> t
 				| _ -> ODKPlain)
 			| TDynamic t when (follow t != t_dynamic) ->
@@ -3025,7 +3025,7 @@ and type_object_decl ctx fl with_type p =
 			| _ ->
 				ODKPlain
 		in
-		loop t
+		loop false t
 	| _ ->
 		ODKPlain
 	) in