From 75eb8a49842075bcaa2878b262443b48aafec2ab Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 24 Jul 2012 14:55:10 +0200 Subject: use hasAllFlags to detect gadt skolems trying to compromise between - easy discovery of what special mix of flags identifies a gadt skolem - ensuring that hasAllFlags is used and not hasFlag keeping the secret combo close to the creator/detector methods instead of moving them to Flags ideally, we'd allocate a new bit in Flags, but that's to invasive right now these symbols are also relatively short-lived: thet are created in adaptConstrPattern and removed at the end of typedCase --- src/reflect/scala/reflect/internal/Symbols.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 10d02376b1..b82d483893 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -585,10 +585,16 @@ trait Symbols extends api.Symbols { self: SymbolTable => skolem setInfo (basis.info cloneInfo skolem) } + // don't test directly -- use isGADTSkolem + // used to single out a gadt skolem symbol in deskolemizeGADT + // gadtskolems are created in adaptConstrPattern and removed at the end of typedCase + @inline final protected[Symbols] def GADT_SKOLEM_FLAGS = CASEACCESSOR | SYNTHETIC + // flags set up to maintain TypeSkolem's invariant: origin.isInstanceOf[Symbol] == !hasFlag(EXISTENTIAL) - // CASEACCESSOR | SYNTHETIC used to single this symbol out in deskolemizeGADT + // GADT_SKOLEM_FLAGS (== CASEACCESSOR | SYNTHETIC) used to single this symbol out in deskolemizeGADT + // TODO: it would be better to allocate a new bit in the flag long for GADTSkolem rather than OR'ing together CASEACCESSOR | SYNTHETIC def newGADTSkolem(name: TypeName, origin: Symbol, info: Type): TypeSkolem = - newTypeSkolemSymbol(name, origin, origin.pos, origin.flags & ~(EXISTENTIAL | PARAM) | CASEACCESSOR | SYNTHETIC) setInfo info + newTypeSkolemSymbol(name, origin, origin.pos, origin.flags & ~(EXISTENTIAL | PARAM) | GADT_SKOLEM_FLAGS) setInfo info final def freshExistential(suffix: String): TypeSymbol = newExistential(freshExistentialName(suffix), pos) @@ -2958,7 +2964,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => // a type symbol bound by an existential type, for instance the T in // List[T] forSome { type T } override def isExistentialSkolem = this hasFlag EXISTENTIAL - override def isGADTSkolem = this hasFlag CASEACCESSOR | SYNTHETIC + override def isGADTSkolem = this hasAllFlags GADT_SKOLEM_FLAGS override def isTypeSkolem = this hasFlag PARAM override def isAbstractType = this hasFlag DEFERRED -- cgit v1.2.3