Skip to content

Commit 9a6c517

Browse files
Add generic parameters
Something is going wrong with the stub generation. Fixes #9774
1 parent b4a129a commit 9a6c517

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ trait Validateable {
7878
}
7979
}
8080

81-
boolean validate(Closure... adHocConstraintsClosures) {
81+
boolean validate(Closure<?>... adHocConstraintsClosures) {
8282
validate(null, null, adHocConstraintsClosures)
8383
}
8484

85-
boolean validate(Map<String, Object> params, Closure... adHocConstraintsClosures) {
85+
boolean validate(Map<String, Object> params, Closure<?>... adHocConstraintsClosures) {
8686
validate(null, params, adHocConstraintsClosures)
8787
}
8888

89-
boolean validate(List fieldsToValidate, Closure... adHocConstraintsClosures) {
89+
boolean validate(List fieldsToValidate, Closure<?>... adHocConstraintsClosures) {
9090
validate(fieldsToValidate, null, adHocConstraintsClosures)
9191
}
9292

93-
boolean validate(List fieldsToValidate, Map<String, Object> params, Closure... adHocConstraintsClosures) {
93+
boolean validate(List fieldsToValidate, Map<String, Object> params, Closure<?>... adHocConstraintsClosures) {
9494
beforeValidateHelper.invokeBeforeValidate(this, fieldsToValidate)
9595

9696
boolean shouldInherit = Boolean.valueOf(params?.inherit?.toString() ?: 'true')
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package grails.validation;
2+
3+
4+
// https://github.com/grails/grails-core/issues/9774
5+
public class SomeJavaClass {
6+
MyValidateable someValidateable;
7+
}

grails-test-suite-uber/src/test/groovy/grails/validation/ValidateableTraitSpec.groovy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,24 @@ class ValidateableTraitSpec extends Specification {
278278
validateable.errors['superName']?.code == 'nullable'
279279
validateable.errors['subName']?.code == 'nullable'
280280
}
281+
282+
@Issue('grails/grails-core#9774')
283+
void 'test a Java class which references a Groovy class marked with @Validateable'() {
284+
given:
285+
def obj = new SomeJavaClass()
286+
287+
when:
288+
obj.someValidateable = new MyValidateable(name: 'jeff')
289+
290+
then:
291+
!obj.someValidateable.validate(['name'])
292+
293+
when:
294+
obj.someValidateable = new MyValidateable(name: 'Jeff')
295+
296+
then:
297+
obj.someValidateable.validate(['name'])
298+
}
281299
}
282300

283301
class MyValidateable implements Validateable {

0 commit comments

Comments
 (0)