Skip to content

Commit

Permalink
GRECLIPSE-554 Just simple fix and test for Groovy-like way of accessi…
Browse files Browse the repository at this point in the history
…ng map values. Treat any map value as Object.
  • Loading branch information
DenisMurashev committed Oct 22, 2014
1 parent c952492 commit 7ea792e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,22 @@ public void testInstanceOf4() throws Exception {
assertType(contents, start, end, "java.lang.Integer");
}

// GRECLIPSE-554
public void testMapEntries1() throws Exception {
String contents =
"def map = [:]\n" +
"map.foo = 1\n" +
"print map.foo";

int start = contents.lastIndexOf("map");
int end = start + "map".length();
assertType(contents, start, end, "java.util.Map<java.lang.Object,java.lang.Object>");

start = contents.lastIndexOf("foo");
end = start + "foo".length();
assertType(contents, start, end, "java.lang.Object");
}

public void testThisInInnerClass1() {
String contents =
"class A {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,10 @@ private TypeLookupResult lookupExpressionType(Expression node, ClassNode objectE
}
}
}
if (result.confidence == TypeConfidence.UNKNOWN && VariableScope.MAP_CLASS_NODE.equals(result.declaringType)) {
result = new TypeLookupResult(VariableScope.OBJECT_CLASS_NODE, result.declaringType, result.declaration,
TypeConfidence.POTENTIAL, result.scope);
}
return result;
}

Expand Down

0 comments on commit 7ea792e

Please sign in to comment.