@@ -414,11 +414,11 @@ class TypeInferenceSTCTest extends StaticTypeCheckingTestCase {
414
414
415
415
// GROOVY-8965
416
416
void testMultipleInstanceOf4 () {
417
- [' o' , ' ((Number) o)' ]. each {
417
+ for (o in [' o' , ' ((Number) o)' ]) {
418
418
assertScript """
419
419
def foo(o) {
420
420
if (o instanceof Integer || o instanceof Double) {
421
- ${ it } .floatValue() // ClassCastException
421
+ ${ o } .floatValue() // ClassCastException
422
422
}
423
423
}
424
424
def bar = foo(1.1d)
@@ -429,8 +429,21 @@ class TypeInferenceSTCTest extends StaticTypeCheckingTestCase {
429
429
}
430
430
}
431
431
432
- @NotYetImplemented
432
+ // GROOVY-11559
433
433
void testMultipleInstanceOf5 () {
434
+ assertScript '''
435
+ def foo(o) {
436
+ if (o instanceof Set || o instanceof List) {
437
+ o = "" // NullPointerException
438
+ }
439
+ }
440
+ foo("")
441
+ foo([])
442
+ '''
443
+ }
444
+
445
+ @NotYetImplemented
446
+ void testMultipleInstanceOf6 () {
434
447
assertScript '''
435
448
void test(thing) {
436
449
if (thing instanceof Deque) {
@@ -448,8 +461,8 @@ class TypeInferenceSTCTest extends StaticTypeCheckingTestCase {
448
461
}
449
462
450
463
// GROOVY-10668
451
- void testMultipleInstanceOf6 () {
452
- [' (value as String)' , ' value.toString()' ]. each { string ->
464
+ void testMultipleInstanceOf7 () {
465
+ for (string in [' (value as String)' , ' value.toString()' ]) {
453
466
assertScript """
454
467
def toArray(Object value) {
455
468
def array
@@ -469,7 +482,7 @@ class TypeInferenceSTCTest extends StaticTypeCheckingTestCase {
469
482
}
470
483
471
484
// GROOVY-8828
472
- void testMultipleInstanceOf7 () {
485
+ void testMultipleInstanceOf8 () {
473
486
assertScript '''
474
487
interface Foo { }
475
488
interface Bar { String name() }
0 commit comments