소스 검색

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

* [java,cs] revert some change from 7863

* [tests] add test for stack overflow
Rudy Ges 1 년 전
부모
커밋
039d30e06c
3개의 변경된 파일15개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 3
      src/codegen/gencommon/closuresToClass.ml
  2. 10 0
      tests/misc/cs/projects/Issue11350/Main.hx
  3. 3 0
      tests/misc/cs/projects/Issue11350/compile.hxml

+ 2 - 3
src/codegen/gencommon/closuresToClass.ml

@@ -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 ->

+ 10 - 0
tests/misc/cs/projects/Issue11350/Main.hx

@@ -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 - 0
tests/misc/cs/projects/Issue11350/compile.hxml

@@ -0,0 +1,3 @@
+--main Main
+-cs bin
+-D net-ver=45