Type annotation parsing tests

This commit is contained in:
Roman Shevchenko
2013-02-14 20:15:43 +01:00
parent c9e9b741f0
commit 8df7b744e5
2 changed files with 1086 additions and 226 deletions
@@ -1,9 +1,90 @@
class C<@D T extends @F Object> extends @F Object {
@F int @F[] methodf() throws @F Exception {
a = this instanceof @F C;
C<@F @G C> c = new @Q C<@F C>();
c = (@F Object)c;
Class c = @TA String.class;
@F C.field++;
import java.util.@NotAllowed Date; // illegal
import @IllegalSyntax java.util.Date; // illegal
class SpecSamples {
//
// 1. A type annotation appears before the types simple name ...
//
Map<@NonNull String, @NonEmpty List<@Readonly Document>> files;
{ o.<@NonNull String>m("..."); }
class Folder<F extends @Existing File> { }
Collection<? super @Existing File> files;
class UnmodifiableList<T> implements @Readonly List<@Readonly T> { }
void monitorTemperature() throws @Critical TemperatureException { }
{
new @Interned MyObject();
new @NonEmpty @Readonly List<String>(myNonEmptyStringSet);
myVar.new @Tainted NestedClass();
new <String> @Interned MyObject();
Map.@NonNull Entry ee;
myString = (@NonNull String) myObject;
myString = (@NonNull) myObject; // error: type omitted
isNonNull = myString instanceof @NonNull String;
isNonNull = myString instanceof @NonNull; // error: type omitted
m(@Vernal Date::getDay);
m(List<@English String>::size);
m(Arrays::<@NonNegative Integer>sort);
}
//
// 2. An annotation on a wildcard type argument appears before the wildcard ...
//
void m(MyClass<@Immutable ? extends Comparable<MyClass>> p) { }
//
// 3. The annotation on a given array level prefixes the brackets that introduce that level ...
//
{
@Readonly Document [][] docs1 = new @Readonly Document [2][12]; // array of arrays of read-only documents
Document @Readonly [][] docs2 = new Document @Readonly [2][12]; // read-only array of arrays of documents
Document[] @Readonly [] docs3 = new Document[2] @Readonly [12]; // array of read-only arrays of documents
}
//
// 4. A type annotation is permitted in front of a constructor declaration ...
//
@Immutable SpecSamples() { }
//
// todo[r.sh] 5. It is permitted to explicitly declare the method receiver as the first formal parameter ...
//
/*public String toString(@Readonly MyClass this) { }
public boolean equals(@Readonly MyClass this, @Readonly Object other) { }
SpecSamples(@Receiver SpecSamples this, boolean b) { }
class Outer {
class Middle {
class Inner {
void innerMethod(@A Outer. @B Middle. @C Inner this) { }
}
}
}*/
//
// 6. It is permitted to write an annotation on a type parameter declaration ...
//
class MyClass<@Immutable T> { }
interface WonderfulList<@Reified E> { }
}
File diff suppressed because it is too large Load Diff