Skip to content

Commit 38660af

Browse files
committed
GROOVY-11875: remove extra cast
1 parent 8ecc02e commit 38660af

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,13 +1457,8 @@ public void visitVariableExpression(final VariableExpression expression) {
14571457
} else {
14581458
PropertyExpression pexp = thisPropX(/*implicit-this*/true, expression.getName());
14591459
pexp.getProperty().setSourcePosition(expression);
1460-
pexp.setType(expression.getType());
14611460
pexp.copyNodeMetaData(expression);
14621461
pexp.visit(this);
1463-
1464-
if (!compileStack.isLHS() && !expression.isDynamicTyped()) {
1465-
controller.getOperandStack().doGroovyCast(typeOf(expression));
1466-
}
14671462
}
14681463

14691464
if (!compileStack.isLHS()) {

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2439,9 +2439,33 @@ final class InnerClassTest {
24392439
'''
24402440
}
24412441

2442-
// GROOVY-9618
2442+
// GROOVY-11875
24432443
@Test
24442444
void testNestedPropertyHandling6() {
2445+
assertScript '''import java.util.concurrent.atomic.AtomicBoolean
2446+
class Outer {
2447+
private AtomicBoolean foo = [true]
2448+
boolean isFoo() {
2449+
foo.get()
2450+
}
2451+
Boolean bar() {
2452+
def i = new Inner()
2453+
i.baz()
2454+
}
2455+
class Inner {
2456+
def baz() {
2457+
foo
2458+
}
2459+
}
2460+
}
2461+
2462+
assert new Outer().bar()
2463+
'''
2464+
}
2465+
2466+
// GROOVY-9618
2467+
@Test
2468+
void testNestedPropertyHandling7() {
24452469
assertScript '''
24462470
class Super {
24472471
public static X = 1

0 commit comments

Comments
 (0)