diff --git a/src/checkers/inference/InferenceAnnotatedTypeFactory.java b/src/checkers/inference/InferenceAnnotatedTypeFactory.java index 53d689b9..61bb209e 100644 --- a/src/checkers/inference/InferenceAnnotatedTypeFactory.java +++ b/src/checkers/inference/InferenceAnnotatedTypeFactory.java @@ -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 parameters = + AnnotatedTypes.adaptParameters(this, constructorType, newClassTree.getArguments()); + constructorType.setParameterTypes(parameters); if (viewpointAdapter != null) { viewpointAdapter.viewpointAdaptConstructor(constructorReturnType, constructorElem, constructorType); }