diff options
author | odersky <odersky@gmail.com> | 2016-09-16 20:05:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-16 20:05:25 +0300 |
commit | 186f9551da6c7ace243c8e784f8eb5d6355af419 (patch) | |
tree | 7e54c56f80175cf3e8e93c84cd94d13da8430495 /tests | |
parent | 78a4ff430c4e6f2b9682c8e72e10493fe6fb0d15 (diff) | |
parent | 61f7e085ff1c72eee2b61d708a887ee3a6778167 (diff) | |
download | dotty-186f9551da6c7ace243c8e784f8eb5d6355af419.tar.gz dotty-186f9551da6c7ace243c8e784f8eb5d6355af419.tar.bz2 dotty-186f9551da6c7ace243c8e784f8eb5d6355af419.zip |
Merge pull request #1514 from OlivierBlanvillain/fix-1513
Fix #1513: misaligned by name type parameter type bounds
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/t1513a.scala | 36 | ||||
-rw-r--r-- | tests/pos/t1513b.scala | 25 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/pos/t1513a.scala b/tests/pos/t1513a.scala new file mode 100644 index 000000000..3c4c02376 --- /dev/null +++ b/tests/pos/t1513a.scala @@ -0,0 +1,36 @@ +object Test { + // Heterogeneous lists and natural numbers as defined in shapeless. + + sealed trait HList + sealed trait ::[H, T <: HList] extends HList + sealed trait HNil extends HList + + sealed trait Nat + sealed trait Succ[P <: Nat] extends Nat + sealed trait Zero extends Nat + + // Accessor type class to compute the N'th element of an HList L. + + trait Accessor[L <: HList, N <: Nat] { type Out } + object Accessor { + type Aux[L <: HList, N <: Nat, O] = Accessor[L, N] { type Out = O } + + // (H :: T).At[Zero] = H + implicit def caseZero[H, T <: HList]: Aux[H :: T, Zero, H] = ??? + + // T.At[N] = O => (H :: T).At[Succ[N]] = O + implicit def caseN[H, T <: HList, N <: Nat, O] + (implicit a: Aux[T, N, O]): Aux[H :: T, Succ[N], O] = ??? + } + + case class Proxy[T]() + + def at1[NN <: Nat, OO] (implicit e: Accessor.Aux[String :: HNil, NN, OO]): OO = ??? + def at2[NN <: Nat, OO](p: Proxy[NN])(implicit e: Accessor.Aux[String :: HNil, NN, OO]): OO = ??? + + // N is fixed by a value + at2(Proxy[Zero]): String + + // N is fixed as a type parameter (by name) + at1[NN = Zero]: String +} diff --git a/tests/pos/t1513b.scala b/tests/pos/t1513b.scala new file mode 100644 index 000000000..546649383 --- /dev/null +++ b/tests/pos/t1513b.scala @@ -0,0 +1,25 @@ +object Test { + def f[ + T1 <: String, + T2 <: Int, + T3 <: Boolean + ](a1: T1, a2: T2, a3: T3) = () + + f ("", 1, true) + f[T1 = String] ("", 1, true) + f[T2 = Int] ("", 1, true) + f[T3 = Boolean] ("", 1, true) + f[T1 = String, T2 = Int] ("", 1, true) + f[T1 = String, T3 = Boolean] ("", 1, true) + f[T2 = Int, T1 = String] ("", 1, true) + f[T2 = Int, T3 = Boolean] ("", 1, true) + f[T3 = Boolean, T2 = Int] ("", 1, true) + f[T3 = Boolean, T1 = String] ("", 1, true) + f[T1 = String, T2 = Int, T3 = Boolean]("", 1, true) + f[T1 = String, T3 = Boolean, T2 = Int] ("", 1, true) + f[T2 = Int, T1 = String, T3 = Boolean]("", 1, true) + f[T2 = Int, T3 = Boolean, T1 = String] ("", 1, true) + f[T3 = Boolean, T1 = String, T2 = Int] ("", 1, true) + f[T3 = Boolean, T2 = Int, T1 = String] ("", 1, true) + f[String, Int, Boolean] ("", 1, true) +} |