add source code that does not have location annotations.
[IRC.git] / Robust / JavaGrammar / tests / Test15.java
1 /** A valid JSR-14 Java program, which illustrates some corner-cases in
2  * the 'smart lexer' lookahead implementation of the grammar.  It should
3  * compile correctly using a JSR-14 javac, as well as parse correctly
4  * (no syntax errors) using the java15.cup grammar in this package. */
5 public class Test15<X> {
6     <T> Test15(T t) { }
7     int a = 1, b = 2;
8     C c1 = new C<Integer>(), c2 = new C<B>(), c3 = new C<B[]>();
9     C<B> cc2 = c2;
10     C<B[]> cc3 = c3;
11     boolean d = a < b, e = a < b;
12     int f[] = new int[5];
13     boolean g = a < f[1];
14     boolean h = ( a < f[1] );
15     Object i0 = (A) cc3;
16     Object  i = ( A < B[] > ) cc3;
17     Object  j = ( A < B > ) cc2;
18     Object  k = ( A < A < B[] > >) null;
19     Object  kk= ( A < A < B[] >>) null;
20     Test15<X>.H hh = null;
21     {
22         Test15<X>.H hhh = null;
23         for (boolean l=a<b, m=a<b; a<b ; l=a<b, f[0]++)
24             a=a;
25         for (;d;)
26             b=b;
27         A<Integer> m = c1;
28         if (m instanceof C<Integer>)
29             a=a;
30         for (boolean n = m instanceof C<Integer>,
31                  o = a<b,
32                  p = cc3 instanceof C<B[]>;
33              cc3 instanceof C<B[]>;
34              n = m instanceof C<Integer>,
35                  o = a<b,
36                  p = cc3 instanceof C<B[]>)
37             b=b;
38         for (;m instanceof C<Integer>;)
39             a=a;
40         if (a < b >> 1)
41             ;
42         Object o1 = new A<A<B>>(),
43             o2 = new A<A<A<B>>>(),
44             o3 = new A<A<D<B,A<B>>>>();
45
46         // new, "explicit parameter" version of method invocation.
47         A<Integer> aa = Test15.<A<Integer>>foo();
48         /* although the spec says this should work:
49            A<Integer> aa_ = <A<Integer>>foo();
50          * Neal Gafter has assured me that this is a bug in the spec.
51          * Type arguments are only valid after a dot. */
52
53         // "explicit parameters" with constructor invocations.
54         new <String> K<Integer>("xh"); // prototype 2.2 chokes on this.
55         this.new <String> K<Integer>("xh");
56     }
57     
58     static class A<T> { T t; }
59     static class B { }
60     static class C<T> extends A<T> { }
61     static class D<A,B> { }
62     static class E<X,Y extends A<X>> { }
63     static interface F { }
64     // wildcard bounds.
65     static class G { A<? extends F> a; A<? super C<Integer>> b; }
66     class H { }
67     static class I extends A<Object[]> { }
68     static class J extends A<byte[]> { }
69     class K<Y> { <T>K(T t) { Test15.<T>foo(); } }
70
71     static <T> T foo() { return null; }
72 }