Skip to content

Commit

Permalink
GROOVY-10188
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 9, 2021
1 parent acb58c9 commit 463ecb7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,19 @@ public void testClosureScope8() {
runConformTest(sources, "Outer");
}

@Test // GROOVY-10188
public void testClosureScope9() {
//@formatter:off
String[] sources = {
"Script.groovy",
"List<Integer> numbers = [1,2,3]\n" +
"numbers.each { Number -> print Number.xxx }\n",
};
//@formatter:on

runConformTest(sources, "", "groovy.lang.MissingPropertyException: No such property: xxx for class: java.lang.Integer");
}

@Test
public void testClosureSyntax() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ else if (it.getClass() != PropertyExpression.class) {
}
Tuple2<StringBuilder, Boolean> classNameInfo = makeClassName(doInitialClassTest, name, propertyPart);
name = classNameInfo.getFirst();
// GRECLIPSE add -- GROOVY-10188
if (name == null) return null;
// GRECLIPSE end
doInitialClassTest = classNameInfo.getSecond();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,8 @@ public Expression transform(final Expression exp) {
private static String lookupClassName(final PropertyExpression pe) {
boolean doInitialClassTest = true;
StringBuilder name = new StringBuilder(32);
// this loop builds a name from right to left each name part
// separated by "."
for (Expression expr = pe; expr != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
// this loop builds a name from right to left each name part separated by "."
for (Expression expr = pe; expr != null && name != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
if (expr instanceof VariableExpression) {
VariableExpression ve = (VariableExpression) expr;
// stop at super and this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,8 @@ public Expression transform(final Expression exp) {
private static String lookupClassName(final PropertyExpression pe) {
boolean doInitialClassTest = true;
StringBuilder name = new StringBuilder(32);
// this loop builds a name from right to left each name part
// separated by "."
for (Expression expr = pe; expr != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
// this loop builds a name from right to left each name part separated by "."
for (Expression expr = pe; expr != null && name != null; expr = ((PropertyExpression) expr).getObjectExpression()) {
if (expr instanceof VariableExpression) {
VariableExpression ve = (VariableExpression) expr;
// stop at super and this
Expand Down

0 comments on commit 463ecb7

Please sign in to comment.