src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java
changeset 47248 22d665f53a4a
parent 47216 71c04702a3d5
child 47870 924591048898
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Sep 22 12:00:41 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Sep 22 14:06:11 2017 +0200
@@ -72,6 +72,7 @@
     private Enter enter;
     private Types types;
     private Annotate annotate;
+    private Attr attr;
     private final Resolve resolve;
     private final CompileStates compileStates;
 
@@ -96,6 +97,7 @@
         allowInterfaceBridges = source.allowDefaultMethods();
         allowGraphInference = source.allowGraphInference();
         annotate = Annotate.instance(context);
+        attr = Attr.instance(context);
     }
 
     /** A hashtable mapping bridge methods to the pair of methods they bridge.
@@ -693,8 +695,14 @@
     }
 
     public void visitNewClass(JCNewClass tree) {
-        if (tree.encl != null)
-            tree.encl = translate(tree.encl, erasure(tree.encl.type));
+        if (tree.encl != null) {
+            if (tree.def == null) {
+                tree.encl = translate(tree.encl, erasure(tree.encl.type));
+            } else {
+                tree.args = tree.args.prepend(attr.makeNullCheck(tree.encl));
+                tree.encl = null;
+            }
+        }
 
         Type erasedConstructorType = tree.constructorType != null ?
                 erasure(tree.constructorType) :