Skip to content

Commit 5c10411

Browse files
committed
Merge branch '3.1.x' into 3.2.x
2 parents 936cd8d + ea1d66c commit 5c10411

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

grails-plugin-testing/src/main/groovy/org/grails/compiler/injection/test/TestForTransformation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,9 @@ private IfStatement getAutowiringIfStatement(ClassExpression targetClass, Variab
463463
arguments.addExpression(new ConstantExpression(false));
464464
BlockStatement assignFromApplicationContext = new BlockStatement();
465465
ArgumentListExpression argWithClassName = new ArgumentListExpression();
466-
MethodCallExpression getClassNameMethodCall = new MethodCallExpression(targetClass, "getName", new ArgumentListExpression());
467-
argWithClassName.addExpression(getClassNameMethodCall);
466+
467+
final PropertyExpression classNamePropertyExpression = new PropertyExpression(targetClass, new ConstantExpression("name"));
468+
argWithClassName.addExpression(classNamePropertyExpression);
468469

469470
assignFromApplicationContext.addStatement(new ExpressionStatement(new BinaryExpression(fieldExpression, ASSIGN, new MethodCallExpression(appCtxVar, "getBean", argWithClassName))));
470471
BlockStatement elseBlock = new BlockStatement();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package grails.test.mixin
2+
3+
import grails.artefact.Artefact
4+
import spock.lang.Issue
5+
import spock.lang.Specification
6+
7+
@TestFor(SomeController)
8+
class TestForControllerWithNamePropertySpec extends Specification {
9+
10+
@Issue('grails/grails-core#10363')
11+
void "test referencing a controller with a 'name' property"() {
12+
when:
13+
controller
14+
15+
then:
16+
notThrown ClassCastException
17+
}
18+
}
19+
20+
@Artefact('Controller')
21+
class SomeController {
22+
String name
23+
}

0 commit comments

Comments
 (0)