langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
changeset 29776 984a79b71cfe
parent 29051 7244db2ab176
child 36526 3b41f1c69604
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -190,6 +190,18 @@
         }
     }
 
+    /** Return true if the given tree represents a type elided anonymous class instance creation. */
+    public static boolean isAnonymousDiamond(JCTree tree) {
+        switch(tree.getTag()) {
+            case NEWCLASS:  {
+                JCNewClass nc = (JCNewClass)tree;
+                return nc.def != null && isDiamond(nc.clazz);
+            }
+            case ANNOTATED_TYPE: return isAnonymousDiamond(((JCAnnotatedType)tree).underlyingType);
+            default: return false;
+        }
+    }
+
     public static boolean isEnumInit(JCTree tree) {
         switch (tree.getTag()) {
             case VARDEF: