changeset 2229:20d3735b6a7b

Fix handling of nested types in anonymous class instantiations.
author wmdietl
date Sun, 17 Feb 2013 23:56:15 -0800
parents e8b1c02dad3b
children f35c7284d8dc
files src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Sun Feb 17 20:35:03 2013 -0800
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Sun Feb 17 23:56:15 2013 -0800
@@ -678,6 +678,8 @@
                 }
 
                 case PARAMETERIZED_TYPE: {
+                    List<JCTree> newPath = path.tail;
+
                     if (((JCTypeApply)frame).clazz == tree) {
                         // generic: RAW; noop
                     } else if (((JCTypeApply)frame).arguments.contains(tree)) {
@@ -685,13 +687,21 @@
                         int arg = taframe.arguments.indexOf(tree);
                         p.location = p.location.prepend(new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg));
 
-                        locateNestedTypes(taframe.type, p);
+                        Type typeToUse;
+                        if (newPath.tail != null && newPath.tail.head.hasTag(Tag.NEWCLASS)) {
+                            // If we are within an anonymous class instantiation, use its type,
+                            // because it contains a correctly nested type. 
+                            typeToUse = newPath.tail.head.type;
+                        } else {
+                            typeToUse = taframe.type;
+                        }
+
+                        locateNestedTypes(typeToUse, p);
                     } else {
                         Assert.error("Could not determine type argument position of tree " + tree +
                                 " within frame " + frame);
                     }
 
-                    List<JCTree> newPath = path.tail;
                     resolveFrame(newPath.head, newPath.tail.head, newPath, p);
                     return;
                 }