@@ -59,6 +59,7 @@
import com.sun.tools.javac.tree.TreeInfo ;
import com.sun.tools.javac.util.List ;
import com.sun.tools.javac.util.ListBuffer ;
import java.util.function.BinaryOperator ;
import jdk.jshell.ExpressionToTypeInfo.ExpressionInfo.AnonymousDescription ;
import jdk.jshell.ExpressionToTypeInfo.ExpressionInfo.AnonymousDescription.VariableDesc ;
import jdk.jshell.TaskFactory.AnalyzeTask ;
@@ -406,9 +407,9 @@ private ExpressionInfo treeToInfo(TreePath tp) {
Type accessibleType = accessibleTypes. size() == 1 ? accessibleTypes. head
: types. makeIntersectionType(accessibleTypes);
ei. declareTypeName =
varTypeName(accessibleType, false , AnonymousTypeKind . DECLARE );
varTypeName(accessibleType, (full, pkg) - > full, false , AnonymousTypeKind . DECLARE );
ei. fullTypeName =
varTypeName(enhancedTypesAccessible ? accessibleType : type,
varTypeName(enhancedTypesAccessible ? accessibleType : type, (full, pkg) - > full,
true , AnonymousTypeKind . DECLARE );
ei. displayTypeName =
varTypeName(type, true , AnonymousTypeKind . DISPLAY );
@@ -510,11 +511,15 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
ElementKind . PARAMETER , ElementKind . RESOURCE_VARIABLE );
private String varTypeName (Type type , boolean printIntersectionTypes , AnonymousTypeKind anonymousTypesKind ) {
return varTypeName(type, state. maps:: fullClassNameAndPackageToClass, printIntersectionTypes, anonymousTypesKind);
}
private String varTypeName (Type type , BinaryOperator<String > fullClassNameAndPackageToClass , boolean printIntersectionTypes , AnonymousTypeKind anonymousTypesKind ) {
try {
Function<TypeSymbol , String > anonymousClass2DeclareName =
cs - > anon2Name. computeIfAbsent(cs, state. eval:: computeDeclareName);
TypePrinter tp = new TypePrinter (at. messages(),
state . maps :: fullClassNameAndPackageToClass, anonymousClass2DeclareName,
fullClassNameAndPackageToClass, anonymousClass2DeclareName,
printIntersectionTypes, anonymousTypesKind);
List<Type > captures = types. captures(type);
String res = tp. toString(types. upward(type, captures));