636 asFlagSet(TreeInfo.firstFlag(flags & set1)), |
636 asFlagSet(TreeInfo.firstFlag(flags & set1)), |
637 asFlagSet(TreeInfo.firstFlag(flags & set2))); |
637 asFlagSet(TreeInfo.firstFlag(flags & set2))); |
638 return false; |
638 return false; |
639 } else |
639 } else |
640 return true; |
640 return true; |
|
641 } |
|
642 |
|
643 /** Check that the type inferred using the diamond operator does not contain |
|
644 * non-denotable types such as captured types or intersection types. |
|
645 * @param t the type inferred using the diamond operator |
|
646 */ |
|
647 List<Type> checkDiamond(ClassType t) { |
|
648 DiamondTypeChecker dtc = new DiamondTypeChecker(); |
|
649 ListBuffer<Type> buf = ListBuffer.lb(); |
|
650 for (Type arg : t.getTypeArguments()) { |
|
651 if (!dtc.visit(arg, null)) { |
|
652 buf.append(arg); |
|
653 } |
|
654 } |
|
655 return buf.toList(); |
|
656 } |
|
657 |
|
658 static class DiamondTypeChecker extends Types.SimpleVisitor<Boolean, Void> { |
|
659 public Boolean visitType(Type t, Void s) { |
|
660 return true; |
|
661 } |
|
662 @Override |
|
663 public Boolean visitClassType(ClassType t, Void s) { |
|
664 if (t.isCompound()) { |
|
665 return false; |
|
666 } |
|
667 for (Type targ : t.getTypeArguments()) { |
|
668 if (!visit(targ, s)) { |
|
669 return false; |
|
670 } |
|
671 } |
|
672 return true; |
|
673 } |
|
674 @Override |
|
675 public Boolean visitCapturedType(CapturedType t, Void s) { |
|
676 return false; |
|
677 } |
641 } |
678 } |
642 |
679 |
643 /** Check that given modifiers are legal for given symbol and |
680 /** Check that given modifiers are legal for given symbol and |
644 * return modifiers together with any implicit modififiers for that symbol. |
681 * return modifiers together with any implicit modififiers for that symbol. |
645 * Warning: we can't use flags() here since this method |
682 * Warning: we can't use flags() here since this method |