Skip to content

Fix crashes #1083

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

Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -1689,7 +1689,8 @@ private void annotate(
AnnotatedTypeVariable atv =
(AnnotatedTypeVariable)
atypeFactory.getAnnotatedType(
wildcardType.getTypeVariable().asElement());
TypesUtils.wildcardToTypeParam(
wildcardType.getUnderlyingType()));
wildcardType
.getExtendsBound()
.addAnnotations(atv.getUpperBound().getAnnotations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2564,11 +2564,14 @@ protected ParameterizedExecutableType methodFromUse(
// Store varargType before calling setParameterTypes, otherwise we may lose the varargType
// as it is the last element of the original parameterTypes.
method.computeVarargType();
// Adapt parameters, which makes parameters and arguments be the same size for later
// checking.
List<AnnotatedTypeMirror> parameters =
AnnotatedTypes.adaptParameters(this, method, tree.getArguments(), null);
method.setParameterTypes(parameters);

if (inferTypeArgs) {
// Adapt parameters, which makes parameters and arguments be the same size for later
// checking.
List<AnnotatedTypeMirror> parameters =
AnnotatedTypes.adaptParameters(this, method, tree.getArguments(), null);
method.setParameterTypes(parameters);
}
return result;
}

Expand Down Expand Up @@ -2666,7 +2669,10 @@ protected ParameterizedExecutableType methodFromUse(
adaptGetClassReturnTypeToReceiver(methodType, receiverType, tree);
}

methodType.setReturnType(applyCaptureConversion(methodType.getReturnType()));
if (inferTypeArgs) {
methodType.setReturnType(applyCaptureConversion(methodType.getReturnType()));
}

return new ParameterizedExecutableType(methodType, typeargs);
}

Expand Down Expand Up @@ -3053,12 +3059,15 @@ protected ParameterizedExecutableType constructorFromUse(
con.getReturnType().replaceAnnotations(enumAnnos);
}

// Adapt parameters, which makes parameters and arguments be the same size for later
// checking. The vararg type of con has been already computed and stored when calling
// typeVarSubstitutor.substitute.
List<AnnotatedTypeMirror> parameters =
AnnotatedTypes.adaptParameters(this, con, tree.getArguments(), tree);
con.setParameterTypes(parameters);
if (inferTypeArgs) {
// Adapt parameters, which makes parameters and arguments be the same size for later
// checking.
// The vararg type of con has been already computed and stored when calling
// typeVarSubstitutor.substitute.
List<AnnotatedTypeMirror> parameters =
AnnotatedTypes.adaptParameters(this, con, tree.getArguments(), tree);
con.setParameterTypes(parameters);
}

return new ParameterizedExecutableType(con, typeargs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ private InferenceType(
AnnotationMirrorMap<QualifierVar> qualifierVars,
Java8InferenceContext context) {
super(context);
assert type.getKind() == typeMirror.getKind();
assert type.getKind() == typeMirror.getKind()
: "Expected kind: " + type.getKind() + ", but got: " + typeMirror.getKind();
this.type = type.asUse();
this.typeMirror = typeMirror;
this.qualifierVars = qualifierVars;
Expand Down
Loading