Skip to content

Commit

Permalink
8236546: Yield with boolean expression and Object target type crashes…
Browse files Browse the repository at this point in the history
… javac

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

Reviewed-by: mcimadamore
  • Loading branch information
lahodaj committed Jan 13, 2020
1 parent 6fc159f commit 8e2c1c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,7 @@ void resolveJump() {
recordExit(exit);
return ;
} else {
scan(tree.value);
scanExpr(tree.value);
recordExit(new AssignPendingExit(tree, inits, uninits));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -321,6 +321,13 @@ yield switch (i) {
throw new IllegalStateException();
}
}
{
String s = "";
Object o = switch (s) { default -> s != null && s == s; };
if (!(Boolean) o) {
throw new IllegalStateException();
}
}
}

private void throwException() {
Expand Down

0 comments on commit 8e2c1c6

Please sign in to comment.