Skip to content

Commit a2884d5

Browse files
committed
Added test case from SI-6169
1 parent 48f78cd commit a2884d5

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Tests translated from scalac SI-6189 by @retronym
2+
3+
/*
4+
public class Exist<T extends String> {
5+
// java helpfully re-interprets Exist<?> as Exist<? extends String>
6+
public Exist<?> foo() { throw new RuntimeException(); }
7+
}
8+
*/
9+
class Exist[T <: String] {
10+
def foo: Exist[_] = null
11+
}
12+
13+
/*
14+
public class ExistF<T extends ExistF<T>> {
15+
// java helpfully re-interprets ExistF<?> as ExistF<?0 extends ExistF<?0>>
16+
public ExistF<?> foo() { throw new RuntimeException(); }
17+
}
18+
*/
19+
20+
class ExistF[T <: ExistF[T]] {
21+
def foo: ExistF[_] = null
22+
}
23+
24+
/*
25+
public class ExistIndir<T extends String, U extends T> {
26+
// java helpfully re-interprets ExistIndir<?> as ExistIndir<? extends String>
27+
public ExistIndir<?, ?> foo() { throw new RuntimeException(); }
28+
}
29+
*/
30+
31+
class ExistIndir[T <: String, U <: T] {
32+
def foo: ExistIndir[_, _] = null
33+
}
34+
35+
class Test {
36+
class MyExist extends ExistF[MyExist]
37+
// SI-8197, SI-6169: java infers the bounds of existentials, so we have to as well now that SI-1786 is fixed...
38+
def stringy: Exist[_ <: String] = (new Exist[String]).foo
39+
// def fbounded: (ExistF[t] forSome {type t <: ExistF[t] }) = (new MyExist).foo
40+
def indir: ExistIndir[_ <: String, _ <: String] = (new ExistIndir[String, String]).foo
41+
}
42+
43+
44+
/*
45+
public abstract class OP<T> { }
46+
public interface Skin<C extends Skinnable> { }
47+
public interface Skinnable {
48+
OP<Skin<?>> skinProperty();
49+
}
50+
*/
51+
class OP[T]
52+
trait Skin[C <: Skinnable]
53+
trait Skinnable {
54+
def skinProperty: OP[Skin[_]]
55+
}
56+
object ObjectProperty {
57+
implicit def jfxObjectProperty2sfx[T](p: OP[T]): ObjectProperty[T] = new ObjectProperty[T](p)
58+
}
59+
60+
class ObjectProperty[T](val delegate: OP[T])
61+
62+
trait TestWildcardBoundInference {
63+
def delegate: Skinnable
64+
def skin: ObjectProperty[Skin[_ /* inferred: <: Skinnable */]] = ObjectProperty.jfxObjectProperty2sfx(delegate.skinProperty)
65+
skin: ObjectProperty[Skin[_ <: Skinnable]]
66+
67+
def skinCheckInference = delegate.skinProperty
68+
skinCheckInference: ObjectProperty[Skin[_ <: Skinnable]]
69+
}

0 commit comments

Comments
 (0)