Skip to content

Commit cbb0265

Browse files
committed
GROOVY-11875: remove extra cast
1 parent 56eb3e8 commit cbb0265

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,15 +1465,8 @@ public void visitVariableExpression(final VariableExpression expression) {
14651465
} else {
14661466
PropertyExpression pexp = thisPropX(/*implicit-this*/true, expression.getName());
14671467
pexp.getProperty().setSourcePosition(expression);
1468-
pexp.setType(expression.getType());
14691468
pexp.copyNodeMetaData(expression);
14701469
pexp.visit(this);
1471-
1472-
if (!compileStack.isLHS() && !expression.isDynamicTyped()) {
1473-
ClassNode variableType = controller.getTypeChooser()
1474-
.resolveType(expression, controller.getClassNode());
1475-
controller.getOperandStack().doGroovyCast(variableType);
1476-
}
14771470
}
14781471

14791472
if (!compileStack.isLHS()) {

src/test/groovy/gls/innerClass/InnerClassTest.groovy

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,9 +2429,33 @@ final class InnerClassTest {
24292429
'''
24302430
}
24312431

2432-
// GROOVY-9618
2432+
// GROOVY-11875
24332433
@Test
24342434
void testNestedPropertyHandling6() {
2435+
assertScript '''import java.util.concurrent.atomic.AtomicBoolean
2436+
class Outer {
2437+
private AtomicBoolean foo = [true]
2438+
boolean isFoo() {
2439+
foo.get()
2440+
}
2441+
Boolean bar() {
2442+
def i = new Inner()
2443+
i.baz()
2444+
}
2445+
class Inner {
2446+
def baz() {
2447+
foo
2448+
}
2449+
}
2450+
}
2451+
2452+
assert new Outer().bar()
2453+
'''
2454+
}
2455+
2456+
// GROOVY-9618
2457+
@Test
2458+
void testNestedPropertyHandling7() {
24352459
assertScript '''
24362460
class Super {
24372461
public static X = 1

0 commit comments

Comments
 (0)