diff options
author | Martin Odersky <odersky@gmail.com> | 2016-01-31 03:19:12 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-02-09 09:40:53 +0100 |
commit | 44c14b3fb6e5eb6f2b9734f092eef1d85f6b4d18 (patch) | |
tree | 00264730856293ebc55008ac386683a77565183a | |
parent | 322bcfef33834eb1e57c874c5a745faf65e1b8bc (diff) | |
download | dotty-44c14b3fb6e5eb6f2b9734f092eef1d85f6b4d18.tar.gz dotty-44c14b3fb6e5eb6f2b9734f092eef1d85f6b4d18.tar.bz2 dotty-44c14b3fb6e5eb6f2b9734f092eef1d85f6b4d18.zip |
Cleanup of isEffectivelyFinal
EffectivelyFinal came without documentation, so it was not clear
what is was supposed to compute. I looked at the use sites, and it
seems that all they need is "impossible to override". So I changed
the code to do that and dropped the additional condition that
members of modules or final classes were not allowed to be lazy or
mutable. It was not clear to me what that had to do with finality.
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index ba8dde62d..98def3071 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -816,14 +816,11 @@ object SymDenotations { enclClass(symbol, false) } - final def isEffectivelyFinal(implicit ctx: Context): Boolean = { - (this.flags is Flags.PrivateOrFinal) || (!this.owner.isClass) || - ((this.owner.flags is (Flags.ModuleOrFinal)) && (!this.flags.is(Flags.MutableOrLazy))) || - (this.owner.isAnonymousClass) - } + /** A symbol is effectively final if it cannot be overridden in a subclass */ + final def isEffectivelyFinal(implicit ctx: Context): Boolean = + is(PrivateOrFinal) || !owner.isClass || owner.is(ModuleOrFinal) || owner.isAnonymousClass - /** The class containing this denotation which has the given effective name. - */ + /** The class containing this denotation which has the given effective name. */ final def enclosingClassNamed(name: Name)(implicit ctx: Context): Symbol = { val cls = enclosingClass if (cls.effectiveName == name || !cls.exists) cls else cls.owner.enclosingClassNamed(name) |