mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Type annotation parsing tests
This commit is contained in:
+88
-7
@@ -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 type’s 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> { }
|
||||
|
||||
}
|
||||
|
||||
+998
-219
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user