Skip to content

Commit d9444e3

Browse files
committed
Fix GrailsCompileStatic for validateable classes with an inner class. Fixes #10808
1 parent 7169ab6 commit d9444e3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

grails-core/src/main/groovy/org/grails/compiler/ValidateableTypeCheckingExtension.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class ValidateableTypeCheckingExtension extends TypeCheckingDSL {
4141
constraintsClosureCode = constraintsProperty.initialExpression.code
4242
}
4343
constraintsProperty.initialExpression.code = new EmptyStatement()
44+
} else {
45+
newScope()
4446
}
4547
}
4648

grails-test-suite-uber/src/test/groovy/grails/compiler/GrailsCompileStaticCompilationErrorsSpec.groovy

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,35 @@ class SomeClass implements grails.validation.Validateable {
183183
name matches: /[A-Z].*/
184184
}
185185
}
186+
''')
187+
then: 'no errors are thrown'
188+
c
189+
}
190+
191+
@Issue('GRAILS-11242')
192+
void 'Test compiling Validateable with inner class'() {
193+
given:
194+
def gcl = new GroovyClassLoader()
195+
196+
when: 'a class marked with @GrailsCompileStatic invokes dynamic finders on a non-domain class inside of a method marked with TypeCheckingMode.SKIP'
197+
def c = gcl.parseClass('''
198+
package grails.compiler
199+
200+
import groovy.transform.TypeCheckingMode
201+
202+
@GrailsCompileStatic
203+
class SomeClass implements grails.validation.Validateable {
204+
205+
enum TestKind {
206+
BIG,
207+
SMALL
208+
}
209+
210+
String name
211+
static constraints = {
212+
name matches: /[A-Z].*/
213+
}
214+
}
186215
''')
187216
then: 'no errors are thrown'
188217
c

0 commit comments

Comments
 (0)