452 * @param env the current environment |
452 * @param env the current environment |
453 */ |
453 */ |
454 void attribTypeVariables(List<JCTypeParameter> typarams, Env<AttrContext> env) { |
454 void attribTypeVariables(List<JCTypeParameter> typarams, Env<AttrContext> env) { |
455 for (JCTypeParameter tvar : typarams) { |
455 for (JCTypeParameter tvar : typarams) { |
456 TypeVar a = (TypeVar)tvar.type; |
456 TypeVar a = (TypeVar)tvar.type; |
|
457 a.tsym.flags_field |= UNATTRIBUTED; |
|
458 a.bound = Type.noType; |
457 if (!tvar.bounds.isEmpty()) { |
459 if (!tvar.bounds.isEmpty()) { |
458 List<Type> bounds = List.of(attribType(tvar.bounds.head, env)); |
460 List<Type> bounds = List.of(attribType(tvar.bounds.head, env)); |
459 for (JCExpression bound : tvar.bounds.tail) |
461 for (JCExpression bound : tvar.bounds.tail) |
460 bounds = bounds.prepend(attribType(bound, env)); |
462 bounds = bounds.prepend(attribType(bound, env)); |
461 types.setBounds(a, bounds.reverse()); |
463 types.setBounds(a, bounds.reverse()); |
462 } else { |
464 } else { |
463 // if no bounds are given, assume a single bound of |
465 // if no bounds are given, assume a single bound of |
464 // java.lang.Object. |
466 // java.lang.Object. |
465 types.setBounds(a, List.of(syms.objectType)); |
467 types.setBounds(a, List.of(syms.objectType)); |
466 } |
468 } |
467 } |
469 a.tsym.flags_field &= ~UNATTRIBUTED; |
468 } |
470 } |
469 |
|
470 void attribBounds(List<JCTypeParameter> typarams, Env<AttrContext> env) { |
|
471 for (JCTypeParameter tvar : typarams) |
471 for (JCTypeParameter tvar : typarams) |
472 chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type); |
472 chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type); |
473 attribStats(typarams, env); |
473 attribStats(typarams, env); |
|
474 } |
|
475 |
|
476 void attribBounds(List<JCTypeParameter> typarams) { |
474 for (JCTypeParameter typaram : typarams) { |
477 for (JCTypeParameter typaram : typarams) { |
475 Type bound = typaram.type.getUpperBound(); |
478 Type bound = typaram.type.getUpperBound(); |
476 if (bound != null && bound.tsym instanceof ClassSymbol) { |
479 if (bound != null && bound.tsym instanceof ClassSymbol) { |
477 ClassSymbol c = (ClassSymbol)bound.tsym; |
480 ClassSymbol c = (ClassSymbol)bound.tsym; |
478 if ((c.flags_field & COMPOUND) != 0) { |
481 if ((c.flags_field & COMPOUND) != 0) { |
579 Lint lint = env.info.lint.augment(m.attributes_field, m.flags()); |
582 Lint lint = env.info.lint.augment(m.attributes_field, m.flags()); |
580 Lint prevLint = chk.setLint(lint); |
583 Lint prevLint = chk.setLint(lint); |
581 try { |
584 try { |
582 chk.checkDeprecatedAnnotation(tree.pos(), m); |
585 chk.checkDeprecatedAnnotation(tree.pos(), m); |
583 |
586 |
584 attribBounds(tree.typarams, env); |
587 attribBounds(tree.typarams); |
585 |
588 |
586 // If we override any other methods, check that we do so properly. |
589 // If we override any other methods, check that we do so properly. |
587 // JLS ??? |
590 // JLS ??? |
588 chk.checkOverride(tree, m); |
591 chk.checkOverride(tree, m); |
589 |
592 |
2687 |
2690 |
2688 // Validate annotations |
2691 // Validate annotations |
2689 chk.validateAnnotations(tree.mods.annotations, c); |
2692 chk.validateAnnotations(tree.mods.annotations, c); |
2690 |
2693 |
2691 // Validate type parameters, supertype and interfaces. |
2694 // Validate type parameters, supertype and interfaces. |
2692 attribBounds(tree.typarams, env); |
2695 attribBounds(tree.typarams); |
2693 chk.validateTypeParams(tree.typarams); |
2696 chk.validateTypeParams(tree.typarams); |
2694 chk.validate(tree.extending); |
2697 chk.validate(tree.extending); |
2695 chk.validate(tree.implementing); |
2698 chk.validate(tree.implementing); |
2696 |
2699 |
2697 // If this is a non-abstract class, check that it has no abstract |
2700 // If this is a non-abstract class, check that it has no abstract |