Skip to content

Commit

Permalink
move adapt parameter logic from AnnotatedTypeFactory#constructorFromU…
Browse files Browse the repository at this point in the history
…se to here
  • Loading branch information
Ao-senXiong committed Jan 24, 2024
1 parent 9513afe commit 8d8bda6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/checkers/inference/InferenceAnnotatedTypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,19 @@ public ParameterizedExecutableType constructorFromUse(final NewClassTree newClas
addComputedTypeAnnotations(newClassTree, constructorReturnType);

final AnnotatedExecutableType constructorType = AnnotatedTypes.asMemberOf(types, this, constructorReturnType, constructorElem);

// Take adapt parameter logic from AnnotatedTypeFactory#constructorFromUse to
// InferenceAnnotatedTypeFactory#constructorFromUse
// Store varargType before calling setParameterTypes, otherwise we may lose the
// varargType as it is the last element of the original parameterTypes.
// AnnotatedTypes.asMemberOf handles vararg type properly, so we do not need to compute
// vararg type again.
constructorType.computeVarargType();
// 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, constructorType, newClassTree.getArguments());
constructorType.setParameterTypes(parameters);
if (viewpointAdapter != null) {
viewpointAdapter.viewpointAdaptConstructor(constructorReturnType, constructorElem, constructorType);
}
Expand Down

0 comments on commit 8d8bda6

Please sign in to comment.