summaryrefslogtreecommitdiff
path: root/test/pending/run/hk-lub-fail.scala
blob: 0ac4fdd84167c4037c744a02f7799d2475fd5aa2 (plain) (blame)
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
27
28
29
30
31
32
33
34
35
36
37
// Tue Jul 12 16:38:23 PDT 2011

class Bip[T1]
class Foo[T2] extends Bip[T2]
class Bar[T3] extends Bip[T3]

abstract class Factory[CC[X] <: Bip[X]] { }

object Quux1 extends Factory[Foo]
object Quux2 extends Factory[Bar]

object Test {
  // FAIL
  val xs = List(Quux1, Quux2)
  //   error: type mismatch;
  // found   : Quux1.type (with underlying type object Quux1)
  // required: Factory[_ >: Bar with Foo <: Bip]
  //                   ^^     ^^       ^^     ^^ <-- QUIZ: what is missing from these types?

  // The type it should figure out, come on scalac
  type F = Factory[CC] forSome { type X ; type CC[X] >: Bar[X] with Foo[X] <: Bip[X] }

  // No problem
  val ys = List[F](Quux1, Quux2)

  // A repl session to get you started.
/*
  val quux1 = EmptyPackageClass.tpe.member(TermName("Quux1"))
  val quux2 = EmptyPackageClass.tpe.member(TermName("Quux2"))
  val tps   = List(quux1, quux2) map (_.tpe)
  val test  = EmptyPackageClass.tpe.member(TermName("Test"))
  val f     = test.tpe.member(TypeName("F")).tpe

  val fn    = f.normalize.asInstanceOf[ExistentialType]
  val fn2   = fn.underlying.asInstanceOf[TypeRef]
*/
}