You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2022/03/15 19:35:51 UTC
[groovy] branch GROOVY_4_0_X updated: GROOVY-10092, GROOVY-10115, GROOVY-10116, GROOVY-10130: add test cases
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new f3850e9 GROOVY-10092, GROOVY-10115, GROOVY-10116, GROOVY-10130: add test cases
f3850e9 is described below
commit f3850e944c1c12fc30574601e13c3cee6f647917
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Mar 15 14:02:03 2022 -0500
GROOVY-10092, GROOVY-10115, GROOVY-10116, GROOVY-10130: add test cases
---
src/test/groovy/transform/stc/BugsSTCTest.groovy | 13 +++++++++
.../groovy/transform/stc/GenericsSTCTest.groovy | 31 ++++++++++++++++++++++
.../transform/stc/TernaryOperatorSTCTest.groovy | 14 ++++++++++
3 files changed, 58 insertions(+)
diff --git a/src/test/groovy/transform/stc/BugsSTCTest.groovy b/src/test/groovy/transform/stc/BugsSTCTest.groovy
index 488c279..7ec2595 100644
--- a/src/test/groovy/transform/stc/BugsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/BugsSTCTest.groovy
@@ -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 '''
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 3316fd7..1caa599 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -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) { }
diff --git a/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy b/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy
index 43de1a8..93de510 100644
--- a/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy
+++ b/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy
@@ -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 '''