Skip to content

Commit 84aa1de

Browse files
committed
GROOVY-9863
1 parent 55aa25b commit 84aa1de

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java

+21
Original file line numberDiff line numberDiff line change
@@ -5343,4 +5343,25 @@ public void testCompileStatic9799() {
53435343

53445344
runConformTest(sources, "works");
53455345
}
5346+
5347+
@Test
5348+
public void testCompileStatic9863() {
5349+
//@formatter:off
5350+
String[] sources = {
5351+
"Main.groovy",
5352+
"@groovy.transform.CompileStatic\n" +
5353+
"class C {\n" +
5354+
" double getSomeValue() {\n" +
5355+
" 0.0d\n" +
5356+
" }\n" +
5357+
" double test() {\n" +
5358+
" 1.0d + someValue\n" +
5359+
" }\n" +
5360+
"}\n" +
5361+
"print new C().test()\n",
5362+
};
5363+
//@formatter:on
5364+
5365+
runConformTest(sources, "1.0");
5366+
}
53465367
}

base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+5
Original file line numberDiff line numberDiff line change
@@ -4504,6 +4504,11 @@ protected void storeType(Expression exp, ClassNode cn) {
45044504
if (accessedVariable instanceof Parameter) {
45054505
((Parameter) accessedVariable).putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, cn);
45064506
}
4507+
// GRECLIPSE add -- GROOVY-9863
4508+
else if (accessedVariable instanceof PropertyNode && ((PropertyNode) accessedVariable).getField().isSynthetic()) {
4509+
((PropertyNode) accessedVariable).putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, cn);
4510+
}
4511+
// GRECLIPSE end
45074512
if (var.isClosureSharedVariable() && cn != null) {
45084513
List<ClassNode> assignedTypes = typeCheckingContext.closureSharedVariablesAssignmentTypes.get(var);
45094514
if (assignedTypes == null) {

base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+5
Original file line numberDiff line numberDiff line change
@@ -4283,6 +4283,11 @@ protected void storeType(final Expression exp, ClassNode cn) {
42834283
if (accessedVariable instanceof Parameter) {
42844284
((Parameter) accessedVariable).putNodeMetaData(INFERRED_TYPE, cn);
42854285
}
4286+
// GRECLIPSE add -- GROOVY-9863
4287+
else if (accessedVariable instanceof PropertyNode && ((PropertyNode) accessedVariable).getField().isSynthetic()) {
4288+
((PropertyNode) accessedVariable).putNodeMetaData(INFERRED_TYPE, cn);
4289+
}
4290+
// GRECLIPSE end
42864291
if (var.isClosureSharedVariable() && cn != null) {
42874292
List<ClassNode> assignedTypes = typeCheckingContext.closureSharedVariablesAssignmentTypes.computeIfAbsent(var, k -> new LinkedList<ClassNode>());
42884293
assignedTypes.add(cn);

0 commit comments

Comments
 (0)