diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-18 13:22:52 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-18 13:22:52 +0200 |
commit | c71643b9087f1de218dfc2d3a1aefc97984c3b8e (patch) | |
tree | dfd03cbf1663ca33ef781256b293078426003205 /src/dotty/tools/dotc/core/Substituters.scala | |
parent | f2d27cf6b57d6d3fd83818ce07d3aeb14263f897 (diff) | |
download | dotty-c71643b9087f1de218dfc2d3a1aefc97984c3b8e.tar.gz dotty-c71643b9087f1de218dfc2d3a1aefc97984c3b8e.tar.bz2 dotty-c71643b9087f1de218dfc2d3a1aefc97984c3b8e.zip |
Three fixes to substSym
(1) Also handle This types - we need to be able to substitute the class symbol there.
(2) Keep NonMemberSym property when substituting
(3) In p.T, substitute in `p` even if `T` is replaced by substitution.
Diffstat (limited to 'src/dotty/tools/dotc/core/Substituters.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Substituters.scala | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala index 8beb6995e..74388f436 100644 --- a/src/dotty/tools/dotc/core/Substituters.scala +++ b/src/dotty/tools/dotc/core/Substituters.scala @@ -130,12 +130,26 @@ trait Substituters { this: Context => var fs = from var ts = to while (fs.nonEmpty) { - if (fs.head eq sym) return tp.prefix select ts.head + if (fs.head eq sym) + return tp match { + case tp: WithNonMemberSym => NamedType.withNonMemberSym(tp.prefix, ts.head) + case _ => substSym(tp.prefix, from, to, theMap) select ts.head + } fs = fs.tail ts = ts.tail } if (sym.isStatic && !existsStatic(from)) tp else tp.derivedSelect(substSym(tp.prefix, from, to, theMap)) + case tp: ThisType => + val sym = tp.cls + var fs = from + var ts = to + while (fs.nonEmpty) { + if (fs.head eq sym) return ThisType(ts.head.asClass) + fs = fs.tail + ts = ts.tail + } + tp case _: ThisType | _: BoundType | NoPrefix => tp case tp: RefinedType => |