summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-06-04 02:52:18 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-06-04 02:52:18 -0700
commitc84e019622f4e5458530e1d45fd735e4a90efd75 (patch)
tree7fd0fa5e2b968a2c580c51d875533f2dcfdc8774 /src
parentb34313db72b7c42fb403677487bd9ac00257993e (diff)
parent82d2f0c80d5e45df7599a8d4c7d980772d3d4222 (diff)
downloadscala-c84e019622f4e5458530e1d45fd735e4a90efd75.tar.gz
scala-c84e019622f4e5458530e1d45fd735e4a90efd75.tar.bz2
scala-c84e019622f4e5458530e1d45fd735e4a90efd75.zip
Merge pull request #665 from retronym/ticket/5213
SI-5313 Revert to two traversals in substThisAndSym.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 02e11ddd59..a839e44182 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -749,12 +749,18 @@ trait Types extends api.Types { self: SymbolTable =>
def substThis(from: Symbol, to: Symbol): Type =
substThis(from, to.thisType)
- /** Performs both substThis and substSym in one traversal.
+ /** Performs both substThis and substSym, in that order.
+ *
+ * [JZ] Reverted `SubstThisAndSymMap` from 334872, which was not the same as
+ * `substThis(from, to).substSym(symsFrom, symsTo)`.
+ *
+ * `SubstThisAndSymMap` performs a breadth-first map over this type, which meant that
+ * symbol substitution occured before `ThisType` substitution. Consequently, in substitution
+ * of a `SingleType(ThisType(`from`), sym), symbols were rebound to `from` rather than `to`.
*/
- def substThisAndSym(from: Symbol, to: Type, symsFrom: List[Symbol], symsTo: List[Symbol]): Type = {
+ def substThisAndSym(from: Symbol, to: Type, symsFrom: List[Symbol], symsTo: List[Symbol]): Type =
if (symsFrom eq symsTo) substThis(from, to)
- else new SubstThisAndSymMap(from, to, symsFrom, symsTo) apply this
- }
+ else substThis(from, to).substSym(symsFrom, symsTo)
/** Returns all parts of this type which satisfy predicate `p` */
def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p) collect this
@@ -4518,13 +4524,6 @@ trait Types extends api.Types { self: SymbolTable =>
case _ => mapOver(tp)
}
}
- class SubstThisAndSymMap(fromThis: Symbol, toThis: Type, fromSyms: List[Symbol], toSyms: List[Symbol])
- extends SubstSymMap(fromSyms, toSyms) {
- override def apply(tp: Type): Type = tp match {
- case ThisType(sym) if sym == fromThis => apply(toThis)
- case _ => super.apply(tp)
- }
- }
class SubstWildcardMap(from: List[Symbol]) extends TypeMap {
def apply(tp: Type): Type = try {