10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 /**
24 * @test
25 * @bug 8314226
26 * @summary Series of colon-style fallthrough switch cases with guards compiled incorrectly
27 * @enablePreview
28 * @compile T8314226.java
29 * @run main T8314226
30 */
31
32 public class T8314226 {
33 int multipleGuardedCases(Object obj) {
34 switch (obj) {
35 case Integer _ when ((Integer) obj) > 0:
36 case String _ when !((String) obj).isEmpty():
37 return 1;
38 default:
39 return -1;
40 }
41 }
42
43 int multipleGuardedCases2a(Object obj) {
44 switch (obj) {
45 case Integer _ when ((Integer) obj) > 0:
46 case Float _ when ((Float) obj) > 0.0f:
47 case String _ when !((String) obj).isEmpty():
48 return 1;
49 default:
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 /**
24 * @test
25 * @bug 8314226
26 * @summary Series of colon-style fallthrough switch cases with guards compiled incorrectly
27 * @enablePreview
28 * @compile T8314226.java
29 * @run main T8314226
30 * @ignore Verifier error
31 */
32
33 public class T8314226 {
34 int multipleGuardedCases(Object obj) {
35 switch (obj) {
36 case Integer _ when ((Integer) obj) > 0:
37 case String _ when !((String) obj).isEmpty():
38 return 1;
39 default:
40 return -1;
41 }
42 }
43
44 int multipleGuardedCases2a(Object obj) {
45 switch (obj) {
46 case Integer _ when ((Integer) obj) > 0:
47 case Float _ when ((Float) obj) > 0.0f:
48 case String _ when !((String) obj).isEmpty():
49 return 1;
50 default:
|