class A {
void foo() {
Map<String, String> a = Map.of("foo", "bar");
Map<String, String> b = new HashMap<>(a) {{
put("irrelevantKey", "irrelevantValue");
}};
}
}
What did you expect to see?
class A {
void foo() {
Map<String, String> a = Map.of("foo", "bar");
Map<String, String> b = new HashMap<>(a);
b.put("irrelevantKey", "irrelevantValue");
}
}
What did you see instead?
class A {
void foo() {
Map<String, String> a = Map.of("foo", "bar");
Map<String, String> b = new HashMap<>(); // <= No `a` here anymore
b.put("irrelevantKey", "irrelevantValue");
}
}
What is the full stack trace of any errors you encountered?
What did you expect to see?
What did you see instead?
What is the full stack trace of any errors you encountered?
Are you interested in contributing a fix to OpenRewrite?