8236546: Yield with boolean expression and Object target type crashes javac

The whenTrue and whenFalse sets need to be merged for non-boolean expressions.

Reviewed-by: mcimadamore
This commit is contained in:
Jan Lahoda 2020-01-13 10:50:31 +01:00
parent 6fc159f17c
commit 8e2c1c68f6
2 changed files with 10 additions and 3 deletions

View File

@ -2579,7 +2579,7 @@ public class Flow {
recordExit(exit);
return ;
} else {
scan(tree.value);
scanExpr(tree.value);
recordExit(new AssignPendingExit(tree, inits, uninits));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 8214031 8214114
* @bug 8214031 8214114 8236546
* @summary Verify switch expressions embedded in various statements work properly.
* @compile ExpressionSwitchEmbedding.java
* @run main ExpressionSwitchEmbedding
@ -321,6 +321,13 @@ public class ExpressionSwitchEmbedding {
throw new IllegalStateException();
}
}
{
String s = "";
Object o = switch (s) { default -> s != null && s == s; };
if (!(Boolean) o) {
throw new IllegalStateException();
}
}
}
private void throwException() {