diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-10-18 01:50:29 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-10-18 01:50:29 -0700 |
commit | db43498ae719cf0adb06aa56f423a2452f3b1687 (patch) | |
tree | 3173580fe2b6e3faf5b95e80b5f07b4117adb96b | |
parent | 1571af7a8a7e78b67d052f371abc44c751930666 (diff) | |
parent | fbbc767b7a001436185c631b9fb7e688dbdf3a6a (diff) | |
download | scala-db43498ae719cf0adb06aa56f423a2452f3b1687.tar.gz scala-db43498ae719cf0adb06aa56f423a2452f3b1687.tar.bz2 scala-db43498ae719cf0adb06aa56f423a2452f3b1687.zip |
Merge pull request #3045 from retronym/ticket/7688-4
Fix AsSeenFrom of ThisType from TypeVar prefix
-rw-r--r-- | src/reflect/scala/reflect/internal/tpe/TypeMaps.scala | 7 | ||||
-rw-r--r-- | test/files/pos/t7688.scala | 7 |
2 files changed, 10 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 diff --git a/test/files/pos/t7688.scala b/test/files/pos/t7688.scala new file mode 100644 index 0000000000..5a846b97e9 --- /dev/null +++ b/test/files/pos/t7688.scala @@ -0,0 +1,7 @@ +import scala.reflect.macros._ + +class A[C <: Context with Singleton](position: C#Position) + +object A { + def apply(c: Context)(in: c.Tree): A[c.type] = new A(in.pos) +} |