diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-05-04 18:22:34 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-11 10:59:15 -0700 |
commit | 6f0bb49c17ea1a46283777e39ed5ce016aa048a5 (patch) | |
tree | b39d9328148dee9e53e4eb6ae3ac62f3ffd54f32 /src/reflect/scala/reflect/internal/Symbols.scala | |
parent | 6858134fb01315c13df05fbef1b310443f3dac95 (diff) | |
download | scala-6f0bb49c17ea1a46283777e39ed5ce016aa048a5.tar.gz scala-6f0bb49c17ea1a46283777e39ed5ce016aa048a5.tar.bz2 scala-6f0bb49c17ea1a46283777e39ed5ce016aa048a5.zip |
Reduce flag fiddling
There isn't much point to the late* flags in a world where
we're mutating flags left and right in tree and info transformers...
So, lets get rid of the indirection until we can include flags
in a symbol's type history, like we do for its info.
This retires lateDEFERRED (redundant with SYNTHESIZE_IMPL_IN_SUBCLASS).
Since it's introduced so late, it makes little sense to have these
synthetic members go back to DEFERRED. Instead, just set DEFERRED directly.
Also remove unused late* and not* flags.
notPRIVATE subsumes lateFINAL for effective finality (scala/scala-dev#126)
Diffstat (limited to 'src/reflect/scala/reflect/internal/Symbols.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index e438856160..487aadf5e5 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -746,10 +746,10 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def hasGetter = isTerm && nme.isLocalName(name) /** - * Nested modules which have no static owner when ModuleDefs are eliminated (refchecks) are - * given the lateMETHOD flag, which makes them appear as methods after refchecks. + * Nested modules with a non-static owner receive the METHOD flag during UnCurry's info transform. + * (They are replaced by a ClassDef and DefDef for the module accessor during the fields phase.) * - * Note: the lateMETHOD flag is added lazily in the info transformer of the RefChecks phase. + * Note: the METHOD flag is added lazily in the info transformer of the UnCurry phase. * This means that forcing the `sym.info` may change the value of `sym.isMethod`. Forcing the * info is in the responsibility of the caller. Doing it eagerly here was tried (0ccdb151f) but * has proven to lead to bugs (SI-8907). @@ -985,10 +985,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def isEffectivelyFinal: Boolean = ( (this hasFlag FINAL | PACKAGE) || isModuleOrModuleClass && (isTopLevel || !settings.overrideObjects) - || isTerm && ( - isPrivate - || isLocalToBlock - ) + || isTerm && (isPrivate || isLocalToBlock || (hasAllFlags(notPRIVATE | METHOD) && !hasFlag(DEFERRED))) || isClass && originalOwner.isTerm && children.isEmpty // we track known subclasses of term-owned classes, use that infer finality ) /** Is this symbol effectively final or a concrete term member of sealed class whose children do not override it */ @@ -2450,14 +2447,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => */ final def makeNotPrivate(base: Symbol) { if (this.isPrivate) { - setFlag(notPRIVATE) - // Marking these methods final causes problems for proxies which use subclassing. If people - // write their code with no usage of final, we probably shouldn't introduce it ourselves - // unless we know it is safe. ... Unfortunately if they aren't marked final the inliner - // thinks it can't inline them. So once again marking lateFINAL, and in genjvm we no longer - // generate ACC_FINAL on "final" methods which are actually lateFINAL. - if (isMethod && !isDeferred) - setFlag(lateFINAL) + setFlag(notPRIVATE) // this makes it effectively final (isEffectivelyFinal) + // don't set FINAL -- methods not marked final by user should not end up final in bytecode + // inliner will know it's effectively final (notPRIVATE non-deferred method) if (!isStaticModule && !isClassConstructor) { expandName(base) if (isModule) moduleClass.makeNotPrivate(base) @@ -2886,7 +2878,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def owner = { if (Statistics.hotEnabled) Statistics.incCounter(ownerCount) - // a module symbol may have the lateMETHOD flag after refchecks, see isModuleNotMethod + // a non-static module symbol gets the METHOD flag in uncurry's info transform -- see isModuleNotMethod if (!isMethod && needsFlatClasses) rawowner.owner else rawowner } |