Skip to content
Permalink
Browse files
  • Loading branch information
eric-milles committed Mar 15, 2022
1 parent ff345d6 commit 2af61e80a51d55dfb27abe217e91a7bbcad0fba5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
@@ -1102,6 +1102,19 @@ Printer
'''
}

// GROOVY-10092
void testAssignBooleanValueToFloatLocalVariable() {
assertScript '''
class C {
void test() {
float x = true // internal compiler error: Boolean cannot be cast to Number
}
}
//new C().test()
'TODO: STC error for incompatible assignment'
'''
}

// GROOVY-10424
void testPrivateInnerClassOptimizedBooleanExpr1() {
assertScript '''
@@ -2628,6 +2628,37 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}

// GROOVY-10115
void testCompatibleArgumentsForPlaceholders9() {
assertScript '''
class C<X, T extends X> {
T t
C(T t) {
this.t = t
}
}
new C(null)
'''
}

// GROOVY-10116
void testCompatibleArgumentsForPlaceholders10() {
assertScript '''
class Foo<X,T> {
Foo(Bar<X,T> bar) {
}
}
class Bar<X,T> {
}
class Baz<T> {
void test() {
Foo<T,Long> x = new Foo<T,Long>(new Bar<T,Long>()) // Cannot call Foo#<init>(Bar<T,Long>) with arguments [Bar<T,Long>]
}
}
new Baz().test()
'''
}

void testIncompatibleArgumentsForPlaceholders1() {
shouldFailWithMessages '''
def <T extends Number> T test(T one, T two) { }
@@ -199,6 +199,20 @@ class TernaryOperatorSTCTest extends StaticTypeCheckingTestCase {
'''
}

// GROOVY-10130
void testInstanceofGuard() {
assertScript '''
class A {
}
class B extends A {
}
def test(A x) {
(true && x instanceof B) ? new B[]{x} : null // Cannot convert A to B
}
assert test(null) == null
'''
}

// GROOVY-5523
void testNull1() {
assertScript '''

0 comments on commit 2af61e8

Please sign in to comment.