228 uncheckedHandler.report(pos, msg, args); |
228 uncheckedHandler.report(pos, msg, args); |
229 } |
229 } |
230 |
230 |
231 /** Warn about unsafe vararg method decl. |
231 /** Warn about unsafe vararg method decl. |
232 * @param pos Position to be used for error reporting. |
232 * @param pos Position to be used for error reporting. |
233 * @param sym The deprecated symbol. |
|
234 */ |
233 */ |
235 void warnUnsafeVararg(DiagnosticPosition pos, String key, Object... args) { |
234 void warnUnsafeVararg(DiagnosticPosition pos, String key, Object... args) { |
236 if (lint.isEnabled(LintCategory.VARARGS) && allowSimplifiedVarargs) |
235 if (lint.isEnabled(LintCategory.VARARGS) && allowSimplifiedVarargs) |
237 log.warning(LintCategory.VARARGS, pos, key, args); |
236 log.warning(LintCategory.VARARGS, pos, key, args); |
238 } |
237 } |
395 /* ************************************************************************* |
394 /* ************************************************************************* |
396 * Class name generation |
395 * Class name generation |
397 **************************************************************************/ |
396 **************************************************************************/ |
398 |
397 |
399 /** Return name of local class. |
398 /** Return name of local class. |
400 * This is of the form <enclClass> $ n <classname> |
399 * This is of the form {@code <enclClass> $ n <classname> } |
401 * where |
400 * where |
402 * enclClass is the flat name of the enclosing class, |
401 * enclClass is the flat name of the enclosing class, |
403 * classname is the simple name of the local class |
402 * classname is the simple name of the local class |
404 */ |
403 */ |
405 Name localClassName(ClassSymbol c) { |
404 Name localClassName(ClassSymbol c) { |
598 return t.tag == TYPEVAR || t.tag == ARRAY && isTypeVar(types.elemtype(t)); |
597 return t.tag == TYPEVAR || t.tag == ARRAY && isTypeVar(types.elemtype(t)); |
599 } |
598 } |
600 |
599 |
601 /** Check that a type is within some bounds. |
600 /** Check that a type is within some bounds. |
602 * |
601 * |
603 * Used in TypeApply to verify that, e.g., X in V<X> is a valid |
602 * Used in TypeApply to verify that, e.g., X in {@code V<X>} is a valid |
604 * type argument. |
603 * type argument. |
605 * @param pos Position to be used for error reporting. |
|
606 * @param a The type that should be bounded by bs. |
604 * @param a The type that should be bounded by bs. |
607 * @param bs The bound. |
605 * @param bound The bound. |
608 */ |
606 */ |
609 private boolean checkExtends(Type a, Type bound) { |
607 private boolean checkExtends(Type a, Type bound) { |
610 if (a.isUnbound()) { |
608 if (a.isUnbound()) { |
611 return true; |
609 return true; |
612 } else if (a.tag != WILDCARD) { |
610 } else if (a.tag != WILDCARD) { |
1260 /** Validate a type expression. That is, |
1258 /** Validate a type expression. That is, |
1261 * check that all type arguments of a parametric type are within |
1259 * check that all type arguments of a parametric type are within |
1262 * their bounds. This must be done in a second phase after type attributon |
1260 * their bounds. This must be done in a second phase after type attributon |
1263 * since a class might have a subclass as type parameter bound. E.g: |
1261 * since a class might have a subclass as type parameter bound. E.g: |
1264 * |
1262 * |
|
1263 * <pre>{@code |
1265 * class B<A extends C> { ... } |
1264 * class B<A extends C> { ... } |
1266 * class C extends B<C> { ... } |
1265 * class C extends B<C> { ... } |
|
1266 * }</pre> |
1267 * |
1267 * |
1268 * and we can't make sure that the bound is already attributed because |
1268 * and we can't make sure that the bound is already attributed because |
1269 * of possible cycles. |
1269 * of possible cycles. |
1270 * |
1270 * |
1271 * Visitor method: Validate a type expression, if it is not null, catching |
1271 * Visitor method: Validate a type expression, if it is not null, catching |
2572 * Validate the proposed container 'containedBy' on the |
2572 * Validate the proposed container 'containedBy' on the |
2573 * annotation type symbol 's'. Report errors at position |
2573 * annotation type symbol 's'. Report errors at position |
2574 * 'pos'. |
2574 * 'pos'. |
2575 * |
2575 * |
2576 * @param s The (annotation)type declaration annotated with a @ContainedBy |
2576 * @param s The (annotation)type declaration annotated with a @ContainedBy |
2577 * @param containerAnno the @ContainedBy on 's' |
2577 * @param containedBy the @ContainedBy on 's' |
2578 * @param pos where to report errors |
2578 * @param pos where to report errors |
2579 */ |
2579 */ |
2580 public void validateContainedBy(TypeSymbol s, Attribute.Compound containedBy, DiagnosticPosition pos) { |
2580 public void validateContainedBy(TypeSymbol s, Attribute.Compound containedBy, DiagnosticPosition pos) { |
2581 Assert.check(types.isSameType(containedBy.type, syms.containedByType)); |
2581 Assert.check(types.isSameType(containedBy.type, syms.containedByType)); |
2582 |
2582 |
3179 /** Check that static single-type import is not already imported or top-level defined, |
3179 /** Check that static single-type import is not already imported or top-level defined, |
3180 * but make an exception for two single-type imports which denote the same type. |
3180 * but make an exception for two single-type imports which denote the same type. |
3181 * @param pos Position for error reporting. |
3181 * @param pos Position for error reporting. |
3182 * @param sym The symbol. |
3182 * @param sym The symbol. |
3183 * @param s The scope |
3183 * @param s The scope |
3184 * @param staticImport Whether or not this was a static import |
|
3185 */ |
3184 */ |
3186 boolean checkUniqueStaticImport(DiagnosticPosition pos, Symbol sym, Scope s) { |
3185 boolean checkUniqueStaticImport(DiagnosticPosition pos, Symbol sym, Scope s) { |
3187 return checkUniqueImport(pos, sym, s, true); |
3186 return checkUniqueImport(pos, sym, s, true); |
3188 } |
3187 } |
3189 |
3188 |