File: t6895.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (26 lines) | stat: -rw-r--r-- 735 bytes parent folder | download | duplicates (4)
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
trait Foo[F1[F1_P]]
trait Bar[F2[F2_P]]

class Test {
  def barFoo[F3[F3_P]]: Foo[F3] = ???

  // Now we can define a couple of type aliases:
  type M[X1] = String
  type N[X2] = Bar[M]

  // val ok1: Foo[N] = barFoo
  // Foo[?F3] <:< Foo[Test.this.N]
  //   [X2]Test.this.N[X2] <:< [F3_P]?F3[F3_P]
  //      Test.this.N[X2] <:< ?F3[X2]
  //        true, ?F3=N

  // val ok2: Foo[({type L[X] = Bar[M]})#L] = barFoo[N]

  val nok: Foo[({type L[X3] = Bar[M]})#L] = barFoo /* Type inference can't unify F with L */
  // Foo[?F3] <:< Foo[[X3]Bar[[X1]String]]
  //   [X3]Bar[[X1]String] <:< ?F3
  //     [X3]Bar[[X1]String] <:< [F3_P]?F3[F3_P]
  //        Bar[[X1]String] <:< ?F3[X3]
  //          X3 <:< [X1]String
  //            false
}