aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-02-11 00:11:25 +1100
committerMartin Odersky <odersky@gmail.com>2017-04-04 13:29:38 +0200
commitc245600ed4bfd4af6f2b45e8cae2cf5a63ddeaf0 (patch)
tree8a116622aacd162b206a9dfcacab5db74e3427e8 /compiler/src/dotty/tools/dotc/core/SymDenotations.scala
parent8f3c9a80cd464a962abeede37087ed52a6d9970a (diff)
downloaddotty-c245600ed4bfd4af6f2b45e8cae2cf5a63ddeaf0.tar.gz
dotty-c245600ed4bfd4af6f2b45e8cae2cf5a63ddeaf0.tar.bz2
dotty-c245600ed4bfd4af6f2b45e8cae2cf5a63ddeaf0.zip
More fine-grained distinctions when flags are defined.
Flags like Trait are in fact not always defined when a symbol is created. For symbols loaded from class files, this flag, and some other is defined only once the classfile has been loaded. But this happens in general before the symbol is completed. We model this distinction by separating from the `FromStartFlags` set a new set `AfterLoadFlags` and distinguishing between the two sets in `SymDenotations#is`. Test case is enum-Option.scala. This erroneously complained before that `Enum` was not a trait.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/SymDenotations.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
index db96463e0..27782698d 100644
--- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -163,26 +163,31 @@ object SymDenotations {
setFlag(flags & mask)
}
+ private def isCurrent(fs: FlagSet) =
+ fs <= (
+ if (myInfo.isInstanceOf[SymbolLoader]) FromStartFlags
+ else AfterLoadFlags)
+
/** Has this denotation one of the flags in `fs` set? */
final def is(fs: FlagSet)(implicit ctx: Context) = {
- (if (fs <= FromStartFlags) myFlags else flags) is fs
+ (if (isCurrent(fs)) myFlags else flags) is fs
}
/** Has this denotation one of the flags in `fs` set, whereas none of the flags
* in `butNot` are set?
*/
final def is(fs: FlagSet, butNot: FlagSet)(implicit ctx: Context) =
- (if (fs <= FromStartFlags && butNot <= FromStartFlags) myFlags else flags) is (fs, butNot)
+ (if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags) is (fs, butNot)
/** Has this denotation all of the flags in `fs` set? */
final def is(fs: FlagConjunction)(implicit ctx: Context) =
- (if (fs <= FromStartFlags) myFlags else flags) is fs
+ (if (isCurrent(fs)) myFlags else flags) is fs
/** Has this denotation all of the flags in `fs` set, whereas none of the flags
* in `butNot` are set?
*/
final def is(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context) =
- (if (fs <= FromStartFlags && butNot <= FromStartFlags) myFlags else flags) is (fs, butNot)
+ (if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags) is (fs, butNot)
/** The type info.
* The info is an instance of TypeType iff this is a type denotation