Skip to content

Commit 463ecb7

Browse files
committed
GROOVY-10188
1 parent acb58c9 commit 463ecb7

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java

+13
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,19 @@ public void testClosureScope8() {
446446
runConformTest(sources, "Outer");
447447
}
448448

449+
@Test // GROOVY-10188
450+
public void testClosureScope9() {
451+
//@formatter:off
452+
String[] sources = {
453+
"Script.groovy",
454+
"List<Integer> numbers = [1,2,3]\n" +
455+
"numbers.each { Number -> print Number.xxx }\n",
456+
};
457+
//@formatter:on
458+
459+
runConformTest(sources, "", "groovy.lang.MissingPropertyException: No such property: xxx for class: java.lang.Integer");
460+
}
461+
449462
@Test
450463
public void testClosureSyntax() {
451464
//@formatter:off

base/org.codehaus.groovy25/src/org/codehaus/groovy/control/ResolveVisitor.java

+3
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,9 @@ else if (it.getClass() != PropertyExpression.class) {
979979
}
980980
Tuple2<StringBuilder, Boolean> classNameInfo = makeClassName(doInitialClassTest, name, propertyPart);
981981
name = classNameInfo.getFirst();
982+
// GRECLIPSE add -- GROOVY-10188
983+
if (name == null) return null;
984+
// GRECLIPSE end
982985
doInitialClassTest = classNameInfo.getSecond();
983986
}
984987
}

base/org.codehaus.groovy30/src/org/codehaus/groovy/control/ResolveVisitor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,8 @@ public Expression transform(final Expression exp) {
885885
private static String lookupClassName(final PropertyExpression pe) {
886886
boolean doInitialClassTest = true;
887887
StringBuilder name = new StringBuilder(32);
888-
// this loop builds a name from right to left each name part
889-
// separated by "."
890-
for (Expression expr = pe; expr != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
888+
// this loop builds a name from right to left each name part separated by "."
889+
for (Expression expr = pe; expr != null && name != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
891890
if (expr instanceof VariableExpression) {
892891
VariableExpression ve = (VariableExpression) expr;
893892
// stop at super and this

base/org.codehaus.groovy40/src/org/codehaus/groovy/control/ResolveVisitor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,8 @@ public Expression transform(final Expression exp) {
880880
private static String lookupClassName(final PropertyExpression pe) {
881881
boolean doInitialClassTest = true;
882882
StringBuilder name = new StringBuilder(32);
883-
// this loop builds a name from right to left each name part
884-
// separated by "."
885-
for (Expression expr = pe; expr != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
883+
// this loop builds a name from right to left each name part separated by "."
884+
for (Expression expr = pe; expr != null && name != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
886885
if (expr instanceof VariableExpression) {
887886
VariableExpression ve = (VariableExpression) expr;
888887
// stop at super and this

0 commit comments

Comments
 (0)