langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
changeset 14057 b4b0377b8dba
parent 13442 41b5b4736385
child 14058 c7ec7facdd20
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Sat Sep 29 09:00:58 2012 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Oct 04 13:04:53 2012 +0100
@@ -245,6 +245,23 @@
         }
     }
 
+    /** Return true if a a tree corresponds to a poly expression. */
+    public static boolean isPoly(JCTree tree, JCTree origin) {
+        switch (tree.getTag()) {
+            case APPLY:
+            case NEWCLASS:
+            case CONDEXPR:
+                return !origin.hasTag(TYPECAST);
+            case LAMBDA:
+            case REFERENCE:
+                return true;
+            case PARENS:
+                return isPoly(((JCParens)tree).expr, origin);
+            default:
+                return false;
+        }
+    }
+
     /**
      * Return true if the AST corresponds to a static select of the kind A.B
      */