From 44c14b3fb6e5eb6f2b9734f092eef1d85f6b4d18 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 31 Jan 2016 03:19:12 +0100 Subject: 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. --- src/dotty/tools/dotc/core/SymDenotations.scala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala') 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) -- cgit v1.2.3