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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
/// FAIL
/// Toplevel
class A {
void /* /// FAIL HERE */ m();
}
/// PASS
/// Toplevel
abstract class X {}
abstract class A
{
void m(X);
}
class B extends A
{
m(x) {}
}
class C extends A
{
// It is OK not to implement m(C x,_), since X has no concrete instance.
}
/// FAIL
/// Toplevel
// This fails since put is not implemented. It should also fail *fast*,
// even though you can imagine many instances for the type.
interface _Map<K, V> {}
<K, V0, V | V <: ?V0> ?V0 /*/// FAIL HERE */ put(_Map<K, V>, V, K);
class MapWrapper<K, V> implements _Map<K, V> {}
/// FAIL
/// TOPLEVEL
class A {
void /*/// FAIL HERE */ fA() {} // default implementation
}
// Try to implement a method for a case equivalent to the default.
// This should create an ambiguity.
fA(A a) {}
/// PASS
/// COMMENT: This tests implementation of a method whose implicit 'this'
/// COMMENT: argument is a parameterized class, and the type parameter
/// COMMENT: does not occur explicitely in the type.
/// COMMENT: (This was a really "interesting" bug to find!)
/// Toplevel
interface A<T>
{
void doSomething();
}
class B<T> implements A<T> { B<T> bfield; }
doSomething(B b) { b.bfield; }
/// FAIL
/// Toplevel
class First {
void paint(java.awt.Graphics g);
}
/*/// FAIL HERE */ paint(java.awt.Component p, g) {
(notNull (g)).drawString("I love java", 20, 20);
}
/// FAIL
/// Toplevel
interface I{}
void foo(I);
foo(# /* /// FAIL HERE */ I x){}
/// FAIL
/// Toplevel
abstract class X {}
void foo(X);
foo(# /* /// FAIL HERE */ X x){}
/// FAIL
/// Toplevel
class A {}
class B extends A{}
void foo(B x);
foo(/* /// FAIL HERE */ A x){}
/// PASS
/// Toplevel
abstract class A<T> {}
class B<T> extends A<T> {
A<T> cons;
}
class C<T> extends A<T> {
A<T> cons;
}
<T> A<T> j(A<A<T>>);
j(B b) = new B(cons: j(b.cons));
j(C c) = new C(cons: j(c.cons));
/// FAIL
/// Toplevel
class A<T> {}
class B<T> extends A<T> {}
<T> void /*/// FAIL HERE */ j(A<A<T>>);
/// FAIL
/// Toplevel
void /*/// FAIL HERE */ f(List<Array<String>>);
/// PASS
f(null);
/// Toplevel
class A { int i; }
int f(?A);
f(A x) = x.i;
f(null) = 0;
/// PASS
assert foo(new Object());
assert !foo("");
/// Toplevel
boolean foo(Object o);
foo(Object o) = true;
foo(String s) = false;
|