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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
t6146b.scala:15: warning: match may not be exhaustive.
It would fail on the following inputs: S2(), S3()
def foo(f: F[Int]) = f match { case X.S1 => }
^
scala> :power
Power mode enabled. :phase is at typer.
import scala.tools.nsc._, intp.global._, definitions._
Try :help or completions for vals._ and power._
scala> val u = rootMirror.universe; import u._, language._
u: $r.intp.global.type = <global>
import u._
import language._
scala> val S1 = typeOf[c.X.S1.type forSome { val c: C[_] }].typeSymbol.tpeHK
S1: u.Type = C.X.S1.type
scala> val S2 = typeOf[O.S2].typeSymbol.tpeHK
S2: u.Type = C.this.S2
scala> val S3 = typeOf[O.S3].typeSymbol.tpeHK
S3: u.Type = O.S3
scala> val S4 = typeOf[S4].typeSymbol.tpeHK
S4: u.Type = S4
scala> val F = typeOf[c.F[_] forSome { val c: C[_] }].typeSymbol.tpeHK
F: u.Type = C.this.F
scala> val fTpe = typeOf[O.type].decl(newTermName("foo")).paramss.head.head.tpe
fTpe: u.Type = O.F[Int]
scala> def memType(sub: Type, scrut: Type): Type =
nestedMemberType(sub.typeSymbol, scrut.prefix, scrut.typeSymbol.owner)
memType: (sub: u.Type, scrut: u.Type)u.Type
scala>
scala> val mt1 = memType(S1, fTpe)
mt1: u.Type = O.X.S1.type
scala> global.typeDeconstruct.show(mt1)
res0: String =
TypeRef(
pre = SingleType(pre = ThisType(object O), object X)
TypeSymbol(class S1 extends C.this.F[T])
)
scala> memType(S2, fTpe)
res1: u.Type = O.S2
scala> memType(S3, fTpe)
res2: u.Type = O.S3
scala> memType(S4, fTpe)
res3: u.Type = S4
scala> :quit
|