blob: 65553ed936194fe5f9e8751ef22954c365ea8dbe (
plain) (
blame)
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
|
// Tests translated from scalac SI-6189 by @retronym
/*
public class Exist<T extends String> {
// java helpfully re-interprets Exist<?> as Exist<? extends String>
public Exist<?> foo() { throw new RuntimeException(); }
}
*/
class Exist[T <: String] {
def foo: Exist[_] = null
}
/*
public class ExistF<T extends ExistF<T>> {
// java helpfully re-interprets ExistF<?> as ExistF<?0 extends ExistF<?0>>
public ExistF<?> foo() { throw new RuntimeException(); }
}
*/
class ExistF[T <: ExistF[T]] {
def foo: ExistF[_] = null
}
/*
public class ExistIndir<T extends String, U extends T> {
// java helpfully re-interprets ExistIndir<?> as ExistIndir<? extends String>
public ExistIndir<?, ?> foo() { throw new RuntimeException(); }
}
*/
class ExistIndir[T <: String, U <: T] {
def foo: ExistIndir[_, _] = null
}
class Test {
class MyExist extends ExistF[MyExist]
// SI-8197, SI-6169: java infers the bounds of existentials, so we have to as well now that SI-1786 is fixed...
def stringy: Exist[_ <: String] = (new Exist[String]).foo
// def fbounded: (ExistF[t] forSome {type t <: ExistF[t] }) = (new MyExist).foo
def indir: ExistIndir[_ <: String, _ <: String] = (new ExistIndir[String, String]).foo
}
/*
public abstract class OP<T> { }
public interface Skin<C extends Skinnable> { }
public interface Skinnable {
OP<Skin<?>> skinProperty();
}
*/
class OP[T]
trait Skin[C <: Skinnable]
trait Skinnable {
def skinProperty: OP[Skin[_]]
}
object ObjectProperty {
implicit def jfxObjectProperty2sfx[T](p: OP[T]): ObjectProperty[T] = new ObjectProperty[T](p)
}
class ObjectProperty[T](val delegate: OP[T])
trait TestWildcardBoundInference {
def delegate: Skinnable
def skin: ObjectProperty[Skin[_ /* inferred: <: Skinnable */]] = ObjectProperty.jfxObjectProperty2sfx(delegate.skinProperty)
skin: ObjectProperty[Skin[_ <: Skinnable]]
def skinCheckInference = delegate.skinProperty
skinCheckInference: ObjectProperty[Skin[_ <: Skinnable]]
}
|