diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-02 17:13:16 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-02 17:19:03 +0100 |
commit | 69b6b892793e45a7158d006cdfb5554edc5db633 (patch) | |
tree | e9f92408d4903f577b4d0d7c849201b15e45c623 /src/dotty/tools/dotc/transform/SymUtils.scala | |
parent | 9d3424da9e34905a20783d4f597d1bb02d0df5d0 (diff) | |
download | dotty-69b6b892793e45a7158d006cdfb5554edc5db633.tar.gz dotty-69b6b892793e45a7158d006cdfb5554edc5db633.tar.bz2 dotty-69b6b892793e45a7158d006cdfb5554edc5db633.zip |
LambdaLift redesign
Simplifications in order to avoid the freqent special
casing of constructors and prepare the way for
proper handling of trait constructors (which cause
problems; see pending/pos/llift.scala.
Diffstat (limited to 'src/dotty/tools/dotc/transform/SymUtils.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/SymUtils.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/transform/SymUtils.scala b/src/dotty/tools/dotc/transform/SymUtils.scala index 9d4fa9788..05305575e 100644 --- a/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/src/dotty/tools/dotc/transform/SymUtils.scala @@ -53,10 +53,16 @@ class SymUtils(val self: Symbol) extends AnyVal { final def skipConstructor(implicit ctx: Context): Symbol = if (self.isConstructor) self.owner else self - /** The logically enclosing method or class for this symbol. - * Instead of constructors one always picks the enclosing class. - */ - final def enclosure(implicit ctx: Context) = self.owner.enclosingMethod.skipConstructor + /** The closest properly enclosing method or class of this symbol. */ + final def enclosure(implicit ctx: Context) = { + self.owner.enclosingMethodOrClass + } + + /** The closest enclosing method or class of this symbol */ + final def enclosingMethodOrClass(implicit ctx: Context): Symbol = + if (self.is(Method, butNot = Label) || self.isClass) self + else if (self.exists) self.owner.enclosingMethodOrClass + else NoSymbol /** Apply symbol/symbol substitution to this symbol */ def subst(from: List[Symbol], to: List[Symbol]): Symbol = { |