Skip to content

Commit 73c993e

Browse files
committed
GROOVY-11600: no implicit outer class argument on inner record ctor call
1 parent c3743cb commit 73c993e

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/main/java/org/codehaus/groovy/classgen/InnerClassVisitorHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ protected static int getObjectDistance(ClassNode cn) {
110110
}
111111

112112
protected static boolean shouldHandleImplicitThisForInnerClass(final ClassNode cn) {
113-
final int explicitOrImplicitStatic = Opcodes.ACC_STATIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ENUM;
114-
return (cn.getModifiers() & explicitOrImplicitStatic) == 0 && (cn instanceof InnerClassNode && !((InnerClassNode) cn).isAnonymous());
113+
final int explicitOrImplicitStatic = Opcodes.ACC_ENUM | Opcodes.ACC_INTERFACE | Opcodes.ACC_RECORD | Opcodes.ACC_STATIC;
114+
return (cn.getModifiers() & explicitOrImplicitStatic) == 0 && (cn instanceof InnerClassNode && !((InnerClassNode) cn).isAnonymous())
115+
&& cn.getAnnotations().stream().noneMatch(aNode -> "groovy.transform.RecordType".equals(aNode.getClassNode().getName())); // GROOVY-11600
115116
}
116117
}

src/test/groovy/transform/stc/ConstructorsSTCTest.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,20 @@ class ConstructorsSTCTest extends StaticTypeCheckingTestCase {
590590
assert new A().test() == ['value']
591591
'''
592592
}
593+
594+
// GROOVY-11600
595+
void testInnerRecordConstructorCall() {
596+
assertScript '''
597+
class C {
598+
record R(int i, Number n) {
599+
}
600+
void test() {
601+
def r = new C.R(1,2)
602+
assert r.i() == 1
603+
assert r.n() == 2
604+
}
605+
}
606+
new C().test()
607+
'''
608+
}
593609
}

0 commit comments

Comments
 (0)