scala/scala — pull request #3045 by retronym (2013-10-17 11:49:37+00:00)
Title: SI-7688 Fix AsSeenFrom of ThisType from TypeVar prefix

Restores behaviour for the AsSeenFrom before the refactoring in b457b6c477.

This commit uniformly considered that a `TypeVar` prefix should not
`matchesPrefixAndClass`; a condition that formerly was only applied if the
type being viewed was a `TypeRef`. This condition was originally added in
cc9e8eda3364d as a backstop for pos/t2797.scala.

This commit leaves that backstop in place where it was, although it expresses
it more directly by checking if `pre baseType clazz` is
`NoType`, which was the case that cropped up in SI-2797:

scala> type T = bc._1.type forSome { val bc: (AnyRef, AnyRef) }
warning: there were 1 feature warning(s); re-run with -feature for details
defined type alias T

scala> val et = typeOf[T].dealias.asInstanceOf[ExistentialType]
et: $r.intp.global.ExistentialType = bc._1.type forSome { val bc: (AnyRef,
AnyRef) }

scala> et.withTypeVars( { x =>
| println(x.prefix.typeSymbol)
| println(x.prefix.typeSymbol.isSubClass(typeOf[Tuple2[_,
_]].typeSymbol))
| println(x.prefix.baseType(typeOf[Tuple2[_, _]].typeSymbol))
| true
| } , reflect.internal.Depth(0))
type bc.type
true

res98: Boolean = true