805 |
805 |
806 while (args.nonEmpty() && tvars.nonEmpty()) { |
806 while (args.nonEmpty() && tvars.nonEmpty()) { |
807 Type actual = types.subst(args.head, |
807 Type actual = types.subst(args.head, |
808 type.tsym.type.getTypeArguments(), |
808 type.tsym.type.getTypeArguments(), |
809 tvars_buf.toList()); |
809 tvars_buf.toList()); |
810 if (!checkExtends(actual, (TypeVar)tvars.head) && |
810 if (!isTypeArgErroneous(actual) && |
811 !tvars.head.getUpperBound().isErroneous()) { |
811 !tvars.head.getUpperBound().isErroneous() && |
|
812 !checkExtends(actual, (TypeVar)tvars.head)) { |
812 return args.head; |
813 return args.head; |
813 } |
814 } |
814 args = args.tail; |
815 args = args.tail; |
815 tvars = tvars.tail; |
816 tvars = tvars.tail; |
816 } |
817 } |
819 tvars = tvars_buf.toList(); |
820 tvars = tvars_buf.toList(); |
820 |
821 |
821 for (Type arg : types.capture(type).getTypeArguments()) { |
822 for (Type arg : types.capture(type).getTypeArguments()) { |
822 if (arg.tag == TYPEVAR && |
823 if (arg.tag == TYPEVAR && |
823 arg.getUpperBound().isErroneous() && |
824 arg.getUpperBound().isErroneous() && |
824 !tvars.head.getUpperBound().isErroneous()) { |
825 !tvars.head.getUpperBound().isErroneous() && |
|
826 !isTypeArgErroneous(args.head)) { |
825 return args.head; |
827 return args.head; |
826 } |
828 } |
827 tvars = tvars.tail; |
829 tvars = tvars.tail; |
|
830 args = args.tail; |
828 } |
831 } |
829 |
832 |
830 return null; |
833 return null; |
831 } |
834 } |
|
835 //where |
|
836 boolean isTypeArgErroneous(Type t) { |
|
837 return isTypeArgErroneous.visit(t); |
|
838 } |
|
839 |
|
840 Types.UnaryVisitor<Boolean> isTypeArgErroneous = new Types.UnaryVisitor<Boolean>() { |
|
841 public Boolean visitType(Type t, Void s) { |
|
842 return t.isErroneous(); |
|
843 } |
|
844 @Override |
|
845 public Boolean visitTypeVar(TypeVar t, Void s) { |
|
846 return visit(t.getUpperBound()); |
|
847 } |
|
848 @Override |
|
849 public Boolean visitCapturedType(CapturedType t, Void s) { |
|
850 return visit(t.getUpperBound()) || |
|
851 visit(t.getLowerBound()); |
|
852 } |
|
853 @Override |
|
854 public Boolean visitWildcardType(WildcardType t, Void s) { |
|
855 return visit(t.type); |
|
856 } |
|
857 }; |
832 |
858 |
833 /** Check that given modifiers are legal for given symbol and |
859 /** Check that given modifiers are legal for given symbol and |
834 * return modifiers together with any implicit modififiers for that symbol. |
860 * return modifiers together with any implicit modififiers for that symbol. |
835 * Warning: we can't use flags() here since this method |
861 * Warning: we can't use flags() here since this method |
836 * is called during class enter, when flags() would cause a premature |
862 * is called during class enter, when flags() would cause a premature |