Skip to content

Commit

Permalink
Don't use assignment context for diamond trees
Browse files Browse the repository at this point in the history
  • Loading branch information
smillst committed Aug 12, 2021
1 parent 76b4c15 commit c56cdb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2637,19 +2637,13 @@ public AnnotatedDeclaredType fromNewClass(NewClassTree newClassTree) {
.tsym
.getTypeParameters()
.nonEmpty()) {
Pair<Tree, AnnotatedTypeMirror> ctx = this.visitorState.getAssignmentContext();
if (ctx != null) {
AnnotatedTypeMirror ctxtype = ctx.second;
TreePath p = getPath(newClassTree);
AnnotatedTypeMirror ctxtype = TypeArgInferenceUtil.assignedTo(this, p);
if (ctxtype != null) {
fromNewClassContextHelper(type, ctxtype);
} else {
TreePath p = getPath(newClassTree);
AnnotatedTypeMirror ctxtype = TypeArgInferenceUtil.assignedTo(this, p);
if (ctxtype != null) {
fromNewClassContextHelper(type, ctxtype);
} else {
// give up trying and set to raw.
type.setIsUnderlyingTypeRaw();
}
// give up trying and set to raw.
type.setIsUnderlyingTypeRaw();
}
}
AnnotatedDeclaredType fromTypeTree =
Expand Down
21 changes: 21 additions & 0 deletions framework/tests/all-systems/Issue4879.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
abstract class L4879<B> {
protected L4879(A4879<B> c) {}
}

class A4879<A> {
static class B4879<T> {
public B4879() {}

A4879<T> build() {
throw new AssertionError();
}
}
}

class Issue4879 {
private final class I4879 extends L4879<Object> {
private I4879() {
super(new A4879.B4879<>().build());
}
}
}

0 comments on commit c56cdb2

Please sign in to comment.