diff options
author | Martin Odersky <odersky@gmail.com> | 2014-11-25 11:19:01 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-11-25 11:19:01 +0100 |
commit | a2884d5338e139fb2ff795b3d08947df58f9b953 (patch) | |
tree | dfa3b78fe47141bf145f6b9fe4664cbe2e8513e5 /tests/pos/wildcardBoundInference.scala | |
parent | 48f78cd66df9f6cd31201ba79b02891a99f1dfbe (diff) | |
download | dotty-a2884d5338e139fb2ff795b3d08947df58f9b953.tar.gz dotty-a2884d5338e139fb2ff795b3d08947df58f9b953.tar.bz2 dotty-a2884d5338e139fb2ff795b3d08947df58f9b953.zip |
Added test case from SI-6169
Diffstat (limited to 'tests/pos/wildcardBoundInference.scala')
-rw-r--r-- | tests/pos/wildcardBoundInference.scala | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/pos/wildcardBoundInference.scala b/tests/pos/wildcardBoundInference.scala new file mode 100644 index 000000000..65553ed93 --- /dev/null +++ b/tests/pos/wildcardBoundInference.scala @@ -0,0 +1,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]] +} |