changeset 3278:3f01e9c496fe

Fix: inner class support doesn't work when outer class type is unbound
author mcimadamore
date Thu, 17 Dec 2015 16:28:01 +0000
parents 7d1d10fd767b
children 71e8f37f46ae
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/SpecializeTypes.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java test/tools/javac/valhalla/typespec/Inner02.java
diffstat 3 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/SpecializeTypes.java	Wed Dec 16 19:01:41 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/SpecializeTypes.java	Thu Dec 17 16:28:01 2015 +0000
@@ -677,7 +677,7 @@
             currentClass = tree.sym;
 			List<Tuple2<Symbol, List<Type>>> varsByOwner = types.typeVarsByOwner(tree.sym);
             if (varsByOwner.stream()
-                    .anyMatch(p -> p.elem0 != tree.sym && p.elem1.stream().anyMatch(types::isAnyTypeVar))) {
+                    .anyMatch(p -> p.elem0.kind == MTH && p.elem1.stream().anyMatch(types::isAnyTypeVar))) {
                 log.warning(tree, "valhalla.not.supported", "class with implicit any type-vars");
             }
             if (types.isAnyfied(tree.sym)) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java	Wed Dec 16 19:01:41 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java	Thu Dec 17 16:28:01 2015 +0000
@@ -315,6 +315,11 @@
                 List<Type> tvars = fa.tvars;
                 descType = types.subst(descType.asMethodType(), tvars, types.erasure(tvars));
             }
+            if (member.enclClass().isInner() && member.isConstructor()) {
+                //add synthetic enclosing parameter
+                descType = types.createMethodTypeWithParameters(descType,
+                        descType.getParameterTypes().prepend(memberOwner.getEnclosingType()));
+            }
             result = new AnyMemberItem(memberItem, typeFunc.apply(descType),
                     memberOwner, descType);
         }
--- a/test/tools/javac/valhalla/typespec/Inner02.java	Wed Dec 16 19:01:41 2015 +0000
+++ b/test/tools/javac/valhalla/typespec/Inner02.java	Thu Dec 17 16:28:01 2015 +0000
@@ -42,7 +42,13 @@
         }
     }
 
+    void test() {
+        new Inner<long>();
+        new Inner<X>();
+    }
+
     public static void main(String[] args) {
-		new Inner02<int>().new Inner<long>().test();
+        new Inner02<int>().new Inner<long>().test();
+        new Inner02<int>().test();
     }
 }
\ No newline at end of file