diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-24 18:51:26 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-24 22:32:32 +0200 |
commit | b56a743edf1fe21ff1f9f070d17e4a23930e59bd (patch) | |
tree | 1da465c9bfaabade7017efb2c70078f4c3fc0780 /src/dotty/tools/dotc/core/Contexts.scala | |
parent | bd8ff1720396bb61d0ef5fede8eb956df663faa5 (diff) | |
download | dotty-b56a743edf1fe21ff1f9f070d17e4a23930e59bd.tar.gz dotty-b56a743edf1fe21ff1f9f070d17e4a23930e59bd.tar.bz2 dotty-b56a743edf1fe21ff1f9f070d17e4a23930e59bd.zip |
Special context for self constructor args
Arguments to this(...) calls need a special contet,
similar to - but different from - the supercall context.
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index 5f0f6ee6a..b221d4083 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -267,7 +267,6 @@ object Contexts { * - as owner: The primary constructor of the class * - as outer context: The context enclosing the class context * - as scope: The parameter accessors in the class context - * - as mode: inSuperCall * * The reasons for this peculiar choice of attributes are as follows: * @@ -283,7 +282,7 @@ object Contexts { */ def superCallContext: Context = { val locals = newScopeWith(owner.decls.filter(_ is ParamAccessor).toList: _*) - superOrThisCallContext(owner.primaryConstructor, locals)//.addMode(Mode.InSuperCall) + superOrThisCallContext(owner.primaryConstructor, locals) } /** The context for the arguments of a this(...) constructor call. @@ -293,20 +292,18 @@ object Contexts { * - as owner: The auxiliary constructor * - as outer context: The context enclosing the enclosing class context * - as scope: The parameters of the auxiliary constructor. - * - as mode: inSuperCall */ - def thisCallContext: Context = { + def thisCallArgContext: Context = { assert(owner.isClassConstructor) val constrCtx = outersIterator.dropWhile(_.outer.owner == owner).next var classCtx = outersIterator.dropWhile(!_.isClassDefContext).next - println(i"locals for this call: ${constrCtx.scope}") - classCtx.superOrThisCallContext(owner, constrCtx.scope) + classCtx.superOrThisCallContext(owner, constrCtx.scope).setTyperState(typerState) } /** The super= or this-call context with given owner and locals. */ - private def superOrThisCallContext(owner: Symbol, locals: Scope): Context = { + private def superOrThisCallContext(owner: Symbol, locals: Scope): FreshContext = { assert(isClassDefContext) - outer.fresh.setOwner(owner).setScope(locals)//.addMode(Mode.InSuperCall) + outer.fresh.setOwner(owner).setScope(locals) } /** The current source file; will be derived from current |