diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-10-15 11:04:43 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-10-17 13:49:50 +0200 |
commit | fbbc767b7a001436185c631b9fb7e688dbdf3a6a (patch) | |
tree | 9a7c79e643594e1e1524502b6817e61cff976296 /src/reflect | |
parent | 810ce7e2790e4da4e3f1d9473ccad5a721847096 (diff) | |
download | scala-fbbc767b7a001436185c631b9fb7e688dbdf3a6a.tar.gz scala-fbbc767b7a001436185c631b9fb7e688dbdf3a6a.tar.bz2 scala-fbbc767b7a001436185c631b9fb7e688dbdf3a6a.zip |
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
<notype>
res98: Boolean = true
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/tpe/TypeMaps.scala | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala index 7e98ac03d5..9a54ad8217 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala @@ -581,6 +581,7 @@ private[internal] trait TypeMaps { else if (!matchesPrefixAndClass(pre, clazz)(tparam.owner)) loop(nextBase.prefix, clazz.owner) else nextBase match { + case NoType => loop(NoType, clazz.owner) // backstop for SI-2797, must remove `SingletonType#isHigherKinded` and run pos/t2797.scala to get here. case applied @ TypeRef(_, _, _) => correspondingTypeArgument(classParam, applied) case ExistentialType(eparams, qtpe) => captureSkolems(eparams) ; loop(qtpe, clazz) case t => abort(s"$tparam in ${tparam.owner} cannot be instantiated from ${seenFromPrefix.widen}") @@ -593,10 +594,8 @@ private[internal] trait TypeMaps { // Since pre may be something like ThisType(A) where trait A { self: B => }, // we have to test the typeSymbol of the widened type, not pre.typeSymbol, or // B will not be considered. - private def matchesPrefixAndClass(pre: Type, clazz: Symbol)(candidate: Symbol) = pre.widen match { - case _: TypeVar => false - case wide => (clazz == candidate) && (wide.typeSymbol isSubClass clazz) - } + private def matchesPrefixAndClass(pre: Type, clazz: Symbol)(candidate: Symbol) = + (clazz == candidate) && (pre.widen.typeSymbol isSubClass clazz) // Whether the annotation tree currently being mapped over has had a This(_) node rewritten. private[this] var wroteAnnotation = false |