Skip to content

Commit b8ff812

Browse files
committed
GROOVY-11854: add test case
1 parent a7bebd3 commit b8ff812

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/test/groovy/gls/innerClass/InnerClassTest.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ final class InnerClassTest {
8989
'''
9090
}
9191

92+
// GROOVY-11854
93+
@Test
94+
void testScriptAIC() {
95+
assertScript '''
96+
def obj = new Object(){}
97+
def aic = obj.getClass()
98+
assert aic.getName().endsWith('$1')
99+
assert aic.getEnclosingClass().getName().startsWith('TestScript')
100+
assert aic.getEnclosingMethod()?.getName() == 'run'
101+
'''
102+
}
103+
92104
// GROOVY-7370, GROOVY-10722
93105
@Test
94106
void testVargsAIC() {
@@ -506,11 +518,15 @@ final class InnerClassTest {
506518
class A {
507519
class B {
508520
String p
521+
String getQ() { WHY }
509522
}
510523
B m() {
511524
return [p:'x'] // calls ScriptBytecodeAdapter.castToType([p:'x'], A$B.class)
525+
// Cannot cast object '{p=x}' with class 'java.util.LinkedHashMap' to class 'A$B' due to:
526+
// GroovyRuntimeException: Could not find named-arg compatible constructor. Expecting one of: A$B(Map), A$B()
512527
}
513528
final String q = 'y'
529+
private static final String WHY = 'y'
514530
}
515531
516532
o = new A().m()
@@ -1562,6 +1578,7 @@ final class InnerClassTest {
15621578
}
15631579
class C extends B {
15641580
}
1581+
15651582
def c = new C()
15661583
assert c.foo() instanceof C
15671584
'''

0 commit comments

Comments
 (0)