Skip to content

Commit

Permalink
Ensure generic casts are inserted where appropriate (eclipse-jdt#2183)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran authored and gayanper committed Sep 7, 2024
1 parent ac79d89 commit 8437e63
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void resolve(BlockScope scope) {
continue;
}
exp.resolveType(scope);
exp.computeConversion(scope, exp.resolvedType, exp.resolvedType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1972,4 +1972,40 @@ public static void main(String argv[]) {
"hello"
);
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2062
// VerifyError with String Templates
public void testIssue2062() {
runConformTest(
new String[] {
"X.java",
"""
import java.lang.StringTemplate.Processor;
import java.util.Map;
public class X {
public static void main(String[] args) throws Exception {
Map<String, String> stuff = Map.of("a", "b");
Transaction tx = new Transaction();
for(Map.Entry<String, String> entry : stuff.entrySet()) {
String name = entry.getKey();
String s = tx.\"""
INSERT INTO settings (a, b) VALUES (\\{name}, \\{entry.getValue()})\""";
System.out.println(s);
}
}
static class Transaction implements Processor<String, Exception> {
@Override
public String process(StringTemplate stringTemplate) throws Exception {
return STR.process(stringTemplate);
}
}
}
"""
},
"INSERT INTO settings (a, b) VALUES (a, b)");
}
}

0 comments on commit 8437e63

Please sign in to comment.