2173 InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); |
2173 InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); |
2174 final boolean isDiamond = TreeInfo.isDiamond(tree); |
2174 final boolean isDiamond = TreeInfo.isDiamond(tree); |
2175 if (isDiamond |
2175 if (isDiamond |
2176 && ((tree.constructorType != null && inferenceContext.free(tree.constructorType)) |
2176 && ((tree.constructorType != null && inferenceContext.free(tree.constructorType)) |
2177 || (tree.clazz.type != null && inferenceContext.free(tree.clazz.type)))) { |
2177 || (tree.clazz.type != null && inferenceContext.free(tree.clazz.type)))) { |
|
2178 final ResultInfo resultInfoForClassDefinition = this.resultInfo; |
2178 inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type), |
2179 inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type), |
2179 instantiatedContext -> { |
2180 instantiatedContext -> { |
2180 tree.constructorType = instantiatedContext.asInstType(tree.constructorType); |
2181 tree.constructorType = instantiatedContext.asInstType(tree.constructorType); |
2181 clazz.type = instantiatedContext.asInstType(clazz.type); |
2182 clazz.type = instantiatedContext.asInstType(clazz.type); |
2182 visitAnonymousClassDefinition(tree, clazz, clazz.type, cdef, localEnv, argtypes, typeargtypes, pkind); |
2183 ResultInfo prevResult = this.resultInfo; |
|
2184 try { |
|
2185 this.resultInfo = resultInfoForClassDefinition; |
|
2186 visitAnonymousClassDefinition(tree, clazz, clazz.type, cdef, |
|
2187 localEnv, argtypes, typeargtypes, pkind); |
|
2188 } finally { |
|
2189 this.resultInfo = prevResult; |
|
2190 } |
2183 }); |
2191 }); |
2184 } else { |
2192 } else { |
2185 if (isDiamond && clazztype.hasTag(CLASS)) { |
2193 if (isDiamond && clazztype.hasTag(CLASS)) { |
2186 List<Type> invalidDiamondArgs = chk.checkDiamondDenotable((ClassType)clazztype); |
2194 List<Type> invalidDiamondArgs = chk.checkDiamondDenotable((ClassType)clazztype); |
2187 if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) { |
2195 if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) { |