30 import com.sun.source.tree.Tree; |
30 import com.sun.source.tree.Tree; |
31 import com.sun.tools.javac.code.*; |
31 import com.sun.tools.javac.code.*; |
32 import com.sun.tools.javac.comp.AttrContext; |
32 import com.sun.tools.javac.comp.AttrContext; |
33 import com.sun.tools.javac.comp.Env; |
33 import com.sun.tools.javac.comp.Env; |
34 import com.sun.tools.javac.tree.JCTree.*; |
34 import com.sun.tools.javac.tree.JCTree.*; |
|
35 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*; |
35 import com.sun.tools.javac.util.*; |
36 import com.sun.tools.javac.util.*; |
36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
37 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
37 import static com.sun.tools.javac.code.Flags.*; |
38 import static com.sun.tools.javac.code.Flags.*; |
38 import static com.sun.tools.javac.code.TypeTag.BOT; |
39 import static com.sun.tools.javac.code.TypeTag.BOT; |
39 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
40 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
262 default: |
263 default: |
263 return false; |
264 return false; |
264 } |
265 } |
265 } |
266 } |
266 |
267 |
267 public static boolean isExplicitLambda(JCLambda lambda) { |
268 /** set 'polyKind' on given tree */ |
268 return lambda.params.isEmpty() || |
269 public static void setPolyKind(JCTree tree, PolyKind pkind) { |
269 lambda.params.head.vartype != null; |
270 switch (tree.getTag()) { |
|
271 case APPLY: |
|
272 ((JCMethodInvocation)tree).polyKind = pkind; |
|
273 break; |
|
274 case NEWCLASS: |
|
275 ((JCNewClass)tree).polyKind = pkind; |
|
276 break; |
|
277 case REFERENCE: |
|
278 ((JCMemberReference)tree).refPolyKind = pkind; |
|
279 break; |
|
280 default: |
|
281 throw new AssertionError("Unexpected tree: " + tree); |
|
282 } |
|
283 } |
|
284 |
|
285 /** set 'varargsElement' on given tree */ |
|
286 public static void setVarargsElement(JCTree tree, Type varargsElement) { |
|
287 switch (tree.getTag()) { |
|
288 case APPLY: |
|
289 ((JCMethodInvocation)tree).varargsElement = varargsElement; |
|
290 break; |
|
291 case NEWCLASS: |
|
292 ((JCNewClass)tree).varargsElement = varargsElement; |
|
293 break; |
|
294 case REFERENCE: |
|
295 ((JCMemberReference)tree).varargsElement = varargsElement; |
|
296 break; |
|
297 default: |
|
298 throw new AssertionError("Unexpected tree: " + tree); |
|
299 } |
270 } |
300 } |
271 |
301 |
272 /** Return true if the tree corresponds to an expression statement */ |
302 /** Return true if the tree corresponds to an expression statement */ |
273 public static boolean isExpressionStatement(JCExpression tree) { |
303 public static boolean isExpressionStatement(JCExpression tree) { |
274 switch(tree.getTag()) { |
304 switch(tree.getTag()) { |