Skip to content

Commit

Permalink
[typeload] lazyfy default type parameter loading
Browse files Browse the repository at this point in the history
see #11161
  • Loading branch information
Simn authored and kLabz committed Apr 27, 2023
1 parent 03925f7 commit b6d9e55
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/typing/typeload.ml
Original file line number Diff line number Diff line change
Expand Up @@ -773,16 +773,20 @@ let rec type_type_param ctx host path get_params p tp =
| None ->
None
| Some ct ->
let t = load_complex_type ctx true ct in
begin match host with
| TPHType ->
()
| TPHConstructor
| TPHMethod
| TPHEnumConstructor ->
display_error ctx.com "Default type parameters are only supported on types" (pos ct)
end;
Some t
let r = exc_protect ctx (fun r ->
r := lazy_processing (fun() -> t);
let t = load_complex_type ctx true ct in
begin match host with
| TPHType ->
()
| TPHConstructor
| TPHMethod
| TPHEnumConstructor ->
display_error ctx.com "Default type parameters are only supported on types" (pos ct)
end;
t
) "default" in
Some (TLazy r)
in
match tp.tp_constraints with
| None ->
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/src/unit/issues/Issue11161.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package unit.issues;

import haxe.ds.Option;

private class TestDefaultTypeParameter<T = Option<String>> {
final data:T;

public function new(data) {
this.data = data;
}
}

class Issue11161 extends Test {
function test() {
utest.Assert.pass();
}
}

0 comments on commit b6d9e55

Please sign in to comment.