From 5d3c189c68aedcbf0c2fa96cff915a0ea09961e9 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Sun, 8 Sep 2024 23:39:28 -0400 Subject: [PATCH 1/2] Invoke viewpoint adapter at correct place --- .../framework/type/AnnotatedTypeFactory.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java index 530b178c177..d570512e67c 100644 --- a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java +++ b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java @@ -2958,13 +2958,12 @@ public ParameterizedExecutableType constructorFromUse(NewClassTree tree) { // AnnotatedTypes.asMemberOf handles vararg type properly, so we do not need to compute // 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 typeParamToTypeArg = AnnotatedTypes.findTypeArguments(processingEnv, this, tree, ctor, con); List typeargs; From 8228faadfaf7b792bde84a6582833e849e317453 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Mon, 30 Sep 2024 16:41:06 -0400 Subject: [PATCH 2/2] Invoke viewpointAdaptConstructor also for super constructor --- .../framework/type/AnnotatedTypeFactory.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java index d570512e67c..048f5fedc10 100644 --- a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java +++ b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java @@ -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());