aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-04 09:30:36 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-09 19:08:59 +0100
commit7194afe4b9a0bb04700b023a1c29047eb6349f88 (patch)
treedbba3f86505fbfba2de2fc5c26db1a55983a93ce /src/dotty/tools/dotc/core/Contexts.scala
parentd28754110576070ea6f94e626005d149a3470d20 (diff)
downloaddotty-7194afe4b9a0bb04700b023a1c29047eb6349f88.tar.gz
dotty-7194afe4b9a0bb04700b023a1c29047eb6349f88.tar.bz2
dotty-7194afe4b9a0bb04700b023a1c29047eb6349f88.zip
Take supercalls into account for statement context
After Mixin, super calls can appear in statemenr sequences. They need to be typechecked and transformed using a special context.
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index de6b0cabf..6293d18d2 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -297,16 +297,21 @@ object Contexts {
def thisCallArgContext: Context = {
assert(owner.isClassConstructor)
val constrCtx = outersIterator.dropWhile(_.outer.owner == owner).next
- var classCtx = outersIterator.dropWhile(!_.isClassDefContext).next
- classCtx.superOrThisCallContext(owner, constrCtx.scope).setTyperState(typerState)
+ superOrThisCallContext(owner, constrCtx.scope).setTyperState(typerState)
}
/** The super= or this-call context with given owner and locals. */
private def superOrThisCallContext(owner: Symbol, locals: Scope): FreshContext = {
- assert(isClassDefContext)
- outer.fresh.setOwner(owner).setScope(locals).setMode(ctx.mode | Mode.InSuperCall)
+ var classCtx = outersIterator.dropWhile(!_.isClassDefContext).next
+ classCtx.outer.fresh.setOwner(owner).setScope(locals).setMode(classCtx.mode | Mode.InSuperCall)
}
+ /** The context of expression `expr` seen as a member of a statement sequence */
+ def exprContext(stat: Tree[_ >: Untyped], exprOwner: Symbol) =
+ if (exprOwner == this.owner) this
+ else if (untpd.isSuperConstrCall(stat) && this.owner.isClass) superCallContext
+ else ctx.fresh.setOwner(exprOwner)
+
/** The current source file; will be derived from current
* compilation unit.
*/