Skip to content

Commit

Permalink
[typer] don't hide abstract type when resolving through @:forward
Browse files Browse the repository at this point in the history
closes #11526
  • Loading branch information
Simn authored and kLabz committed Mar 4, 2024
1 parent 844dce5 commit b00bca0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/typing/fields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ 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 =
f { e with etype = t } (follow_without_type t)
f (mk (TCast(e,None)) t e.epos) (follow_without_type t)
in
let type_field_by_e f e =
f e (follow_without_type e.etype)
Expand Down
19 changes: 19 additions & 0 deletions tests/optimization/src/TestInlineConstructors.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ class NestedInlineClass {
}
}

class P {
public var x:Float;

public inline function new(x = 0)
this.x = x;
}

@:forward
abstract PA(P) to P {
public inline function new(x)
this = new P(x);
}

class TestInlineConstructors extends TestBase {
@:js('return [1,2,3,3];')
static function testArrayInlining() {
Expand Down Expand Up @@ -130,4 +143,10 @@ class TestInlineConstructors extends TestBase {
}
return acc;
}

@:js('return [5];')
static function testForwardAbstract() {
var p2 = {v: new PA(5)};
return [p2.v.x];
}
}

0 comments on commit b00bca0

Please sign in to comment.