From 9f8b8a2674d4c2dbe36aa51249afe0137ae83366 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Wed, 31 Jan 2024 12:55:45 +0100 Subject: [PATCH] Revert @:forward.accessOnAbstract, hack instead see #11527 --- src-json/meta.json | 6 ------ src/typing/fields.ml | 21 ++++++++------------- std/cs/Pointer.hx | 4 +--- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src-json/meta.json b/src-json/meta.json index 645dac758e8..7aca530e7b8 100644 --- a/src-json/meta.json +++ b/src-json/meta.json @@ -394,12 +394,6 @@ "targets": ["TAbstract"], "links": ["https://haxe.org/manual/types-abstract-forward.html"] }, - { - "name": "ForwardAccessOnAbstract", - "metadata": ":forward.accessOnAbstract", - "doc": "Generates @:forward field access on the abstract itself instead of the underlying type.", - "targets": ["TAbstract"] - }, { "name": "ForwardNew", "metadata": ":forward.new", diff --git a/src/typing/fields.ml b/src/typing/fields.ml index 34f107ae02b..0147b0b6ac0 100644 --- a/src/typing/fields.ml +++ b/src/typing/fields.ml @@ -272,6 +272,12 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = | None -> raise Not_found in let type_field_by_et f e t = + let e = match ctx.com.platform with + | Cs -> + {e with etype = t} + | _ -> + mk (TCast(e,None)) t e.epos + in f e (follow_without_type t) in let type_field_by_e f e = @@ -293,15 +299,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = type_field_by_forward f Meta.ForwardStatics a in let type_field_by_forward_member f e a tl = - let f () = - let t = Abstract.get_underlying_type ~return_first:true a tl in - let e = if Meta.has Meta.ForwardAccessOnAbstract a.a_meta then - e - else - mk (TCast(e,None)) t e.epos - in - type_field_by_et f e t - in + let f () = type_field_by_et f e (Abstract.get_underlying_type ~return_first:true a tl) in type_field_by_forward f Meta.Forward a in let type_field_by_typedef f e td tl = @@ -380,10 +378,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = field_access f FHAnon ) | CTypes tl -> - type_field_by_list (fun (t,_) -> - let e = mk (TCast(e,None)) t e.epos in - type_field_by_et type_field_by_type e t - ) tl + type_field_by_list (fun (t,_) -> type_field_by_et type_field_by_type e t) tl | CUnknown -> if not (List.exists (fun (m,_) -> m == r) ctx.monomorphs.perfunction) && not (ctx.untyped && ctx.com.platform = Neko) then ctx.monomorphs.perfunction <- (r,p) :: ctx.monomorphs.perfunction; diff --git a/std/cs/Pointer.hx b/std/cs/Pointer.hx index 4026af75a5e..5d18c665369 100644 --- a/std/cs/Pointer.hx +++ b/std/cs/Pointer.hx @@ -129,7 +129,5 @@ import cs.StdTypes.Int64; @:arrayAccess public static function setp(p:Pointer, at:Int64, val:T):T; } -@:forward -@:forward.accessOnAbstract -abstract PointerAccess(T) {} +@:forward abstract PointerAccess(T) {} #end