You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scalac doesn't do much better by default, but scalac -optimise is very good:
public int test(Object x, Object y) {
int n = x instanceof Integer&& y instanceof Integer?0: (x instanceof String&& y instanceof String?1:2);
return n;
}
It'd be interesting to see if we could get closer to this by improving the optimizations that are built-into the PatternMatcher phase. This would also help when destructuring, e.g. val (x, y) = (1, 2).
The text was updated successfully, but these errors were encountered:
Given:
We generate code that looks like this (when decompiled with cfr):
scalac doesn't do much better by default, but
scalac -optimise
is very good:It'd be interesting to see if we could get closer to this by improving the optimizations that are built-into the PatternMatcher phase. This would also help when destructuring, e.g.
val (x, y) = (1, 2)
.The text was updated successfully, but these errors were encountered: