diff options
author | Martin Odersky <odersky@gmail.com> | 2014-05-28 11:27:11 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-05-30 15:43:02 +0200 |
commit | c2175ec910165308e81c48bd8ca8910c50862be4 (patch) | |
tree | 82af4c43d1167cc0d897d31b1afa855c068f856e /tests | |
parent | 70e785f5d8a583dae127dadf4d9add70bdea71f7 (diff) | |
download | dotty-c2175ec910165308e81c48bd8ca8910c50862be4.tar.gz dotty-c2175ec910165308e81c48bd8ca8910c50862be4.tar.bz2 dotty-c2175ec910165308e81c48bd8ca8910c50862be4.zip |
Avoid classtype checking for refinements.
In a refinement type T { R } we do not need T to be a class. But analyzing the refeinement
type will create a temporary class type. This refinement class has to be treated specially in
what concerns parent types.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/tycons.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/pos/tycons.scala b/tests/pos/tycons.scala new file mode 100644 index 000000000..f138c78be --- /dev/null +++ b/tests/pos/tycons.scala @@ -0,0 +1,22 @@ +class TypeConstructor { + type TypeArg +} + +trait List[+T] extends TypeConstructor { type TypeArg <: T } + +trait Set[T] extends TypeConstructor { type TypeArg <: T } + +object obj extends List[Number] with Set[Exception] { + val x: TypeArg = ??? + val n: Number = x + val e: Exception = x +} + +class Functor[F <: TypeConstructor] { + def map[A, B](f: F { type TypeArg <: A }): F { type TypeArg <: B } +} + +implicit object ListFunctor extends Functor[List] { + def map[A, B](f: List[A]): List[B] = ??? +} + |