mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-21 01:00:54 +08:00
Fix crash when lambda is not used. Fix #500
This commit is contained in:
parent
6f7c2dff2b
commit
5ee332c771
@ -920,7 +920,8 @@ public abstract class DependencyAnalyzer implements DependencyInfo {
|
||||
arguments, indy.getBootstrapMethod(), indy.getBootstrapArguments(),
|
||||
agent);
|
||||
ValueEmitter result = substitutor.substitute(callSite, pe);
|
||||
if (result.getVariable() != null && result.getVariable() != indy.getReceiver()) {
|
||||
if (result.getVariable() != null && result.getVariable() != indy.getReceiver()
|
||||
&& indy.getReceiver() != null) {
|
||||
AssignInstruction assign = new AssignInstruction();
|
||||
assign.setAssignee(result.getVariable());
|
||||
assign.setReceiver(indy.getReceiver());
|
||||
|
@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.Test;
|
||||
@ -72,6 +73,11 @@ public class LambdaTest {
|
||||
assertArrayEquals(new int[] { 1, 2, 3 }, array);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unusedLambda() {
|
||||
Consumer<String> foo = bar -> { };
|
||||
}
|
||||
|
||||
private String acceptIntPredicate(IntPredicate p) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user