Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@ private IfStatement getAutowiringIfStatement(ClassExpression targetClass, Variab
arguments.addExpression(new ConstantExpression(false));
BlockStatement assignFromApplicationContext = new BlockStatement();
ArgumentListExpression argWithClassName = new ArgumentListExpression();
MethodCallExpression getClassNameMethodCall = new MethodCallExpression(targetClass, "getName", new ArgumentListExpression());
argWithClassName.addExpression(getClassNameMethodCall);

final PropertyExpression classNamePropertyExpression = new PropertyExpression(targetClass, new ConstantExpression("name"));
argWithClassName.addExpression(classNamePropertyExpression);

assignFromApplicationContext.addStatement(new ExpressionStatement(new BinaryExpression(fieldExpression, ASSIGN, new MethodCallExpression(appCtxVar, "getBean", argWithClassName))));
BlockStatement elseBlock = new BlockStatement();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package grails.test.mixin

import grails.artefact.Artefact
import spock.lang.Issue
import spock.lang.Specification

@TestFor(SomeController)
class TestForControllerWithNamePropertySpec extends Specification {

@Issue('grails/grails-core#10363')
void "test referencing a controller with a 'name' property"() {
when:
controller

then:
notThrown ClassCastException
}
}

@Artefact('Controller')
class SomeController {
String name
}