Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java,cs] fix stack overflow from closures constraints #11350

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/codegen/gencommon/closuresToClass.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ let traverse gen ?tparam_anon_decl ?tparam_anon_acc (handle_anon_func:texpr->tfu

let rec get_type_params acc t =
match t with
| TInst(( { cl_kind = KTypeParameter constraints } as cl), []) ->
let params = List.fold_left get_type_params acc constraints in
List.filter (fun t -> not (List.memq t acc)) (cl :: params) @ acc;
| TInst(( { cl_kind = KTypeParameter _ } as cl), []) ->
if List.memq cl acc then acc else cl :: acc
| TFun (params,tret) ->
List.fold_left get_type_params acc ( tret :: List.map (fun (_,_,t) -> t) params )
| TDynamic None ->
Expand Down
10 changes: 10 additions & 0 deletions tests/misc/cs/projects/Issue11350/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Main {
public static function main() {}

public static function forComparable<T : Comparable<T>>(): T->T->Void
return (a: T, b: T) -> {}
}

typedef Comparable<T> = {
public function compareTo(that : T) : Int;
}
3 changes: 3 additions & 0 deletions tests/misc/cs/projects/Issue11350/compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--main Main
-cs bin
-D net-ver=45