Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke viewpoint adapter at correct place #903

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2925,9 +2925,12 @@ public ParameterizedExecutableType constructorFromUse(NewClassTree tree) {
AnnotatedExecutableType superCon =
getAnnotatedType(TreeUtils.getSuperConstructor(tree));
constructorFromUsePreSubstitution(tree, superCon);
// no viewpoint adaptation needed for super invocation
superCon =
AnnotatedTypes.asMemberOf(types, this, type, superCon.getElement(), superCon);
// Adapt the result from super constructor as it will be used in anonymous constructor.
if (viewpointAdapter != null) {
viewpointAdapter.viewpointAdaptConstructor(type, ctor, superCon);
}
con.computeVarargType(superCon);
if (superCon.getParameterTypes().size() == con.getParameterTypes().size()) {
con.setParameterTypes(superCon.getParameterTypes());
Expand Down Expand Up @@ -2958,13 +2961,12 @@ public ParameterizedExecutableType constructorFromUse(NewClassTree tree) {
// AnnotatedTypes.asMemberOf handles vararg type properly, so we do not need to compute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this comment and make it understandable?
I'm confused by the ordering of viewpoint adaptation and con.computeVarargType();, which is different in the two branches. Is there a reason for this? If so, can you add a comment?
Some test cases with varargs and anonymous classes would be good to cover all these cases explicitly.

// vararg type again.
con.computeVarargType();
if (viewpointAdapter != null) {
viewpointAdapter.viewpointAdaptConstructor(type, ctor, con);
}
con = AnnotatedTypes.asMemberOf(types, this, type, ctor, con);
}

if (viewpointAdapter != null) {
viewpointAdapter.viewpointAdaptConstructor(type, ctor, con);
}

Map<TypeVariable, AnnotatedTypeMirror> typeParamToTypeArg =
AnnotatedTypes.findTypeArguments(processingEnv, this, tree, ctor, con);
List<AnnotatedTypeMirror> typeargs;
Expand Down