1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
import org.checkerframework.checker.i18n.qual.Localized;
class LocalizedMessage {
@Localized String localize(String s) {
throw new RuntimeException();
}
void localized(@Localized String s) {}
void any(String s) {}
void stringLiteral() {
// :: error: (argument.type.incompatible)
localized("ldskjfldj"); // error
any("lksjdflkjdf");
}
void stringRef(String ref) {
// :: error: (argument.type.incompatible)
localized(ref); // error
any(ref);
}
void localizedRef(@Localized String ref) {
localized(ref);
any(ref);
}
void methodRet(String ref) {
localized(localize(ref));
localized(localize(ref));
}
void concatenation(@Localized String s1, String s2) {
// :: error: (argument.type.incompatible)
localized(s1 + s1); // error
// :: error: (argument.type.incompatible) :: error: (compound.assignment.type.incompatible)
localized(s1 += s1); // error
// :: error: (argument.type.incompatible)
localized(s1 + "m"); // error
// :: error: (argument.type.incompatible)
localized(s1 + s2); // error
// :: error: (argument.type.incompatible)
localized(s2 + s1); // error
// :: error: (argument.type.incompatible)
localized(s2 + "m"); // error
// :: error: (argument.type.incompatible)
localized(s2 + s2); // error
any(s1 + s1);
any(s1 + "m");
any(s1 + s2);
any(s2 + s1);
any(s2 + "m");
any(s2 + s2);
}
}
|