Skip to content

Commit 97c3e5a

Browse files
committed
[jvm] deal with complex static inits
closes #11998
1 parent 4528d44 commit 97c3e5a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/optimization/analyzer.ml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1009,11 +1009,17 @@ module Run = struct
10091009
match e.eexpr with
10101010
| TFunction tf ->
10111011
let get_t t = if ExtType.is_void t then tf.tf_type else t in
1012+
let doesnt_like_complex_expressions = match actx.com.platform with
1013+
| Cpp | Hl | Jvm ->
1014+
true
1015+
| _ ->
1016+
false
1017+
in
10121018
let rec loop e = match e.eexpr with
10131019
| TBlock [e1] ->
10141020
loop e1
10151021
(* If there's a complex expression, keep the function and generate a call to it. *)
1016-
| TBlock _ | TIf _ | TSwitch _ | TTry _ when actx.com.platform = Cpp || actx.com.platform = Hl ->
1022+
| TBlock _ | TIf _ | TSwitch _ | TTry _ when doesnt_like_complex_expressions ->
10171023
raise Exit
10181024
(* Remove generated return *)
10191025
| TReturn (Some e) ->
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package unit.issues;
2+
3+
class Issue11998 extends unit.Test {
4+
static var caughtVar = {
5+
try {
6+
throw "foo";
7+
} catch (s:String) {
8+
s;
9+
}
10+
}
11+
12+
public function test() {
13+
eq("foo", caughtVar);
14+
}
15+
}

0 commit comments

Comments
 (0)