aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-27 18:55:50 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:11 +0200
commitea96ecda77ab99969a65b66173260e66b199be74 (patch)
tree18ee2854bc43b1d8ca55d117e74dfcd0350249b1 /compiler
parent21ab9a1355036aa953db4e1f87c8f0f9a06506b5 (diff)
downloaddotty-ea96ecda77ab99969a65b66173260e66b199be74.tar.gz
dotty-ea96ecda77ab99969a65b66173260e66b199be74.tar.bz2
dotty-ea96ecda77ab99969a65b66173260e66b199be74.zip
Get rid of SuperAccessor flag
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Flags.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala10
-rw-r--r--compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/transform/SymUtils.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ValueClasses.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/typer/RefChecks.scala2
12 files changed, 23 insertions, 17 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Flags.scala b/compiler/src/dotty/tools/dotc/core/Flags.scala
index 8a1e14c63..ef3261719 100644
--- a/compiler/src/dotty/tools/dotc/core/Flags.scala
+++ b/compiler/src/dotty/tools/dotc/core/Flags.scala
@@ -311,12 +311,12 @@ object Flags {
final val CaseAccessorOrBaseTypeArg = CaseAccessor.toCommonFlags
/** A super accessor */
- final val SuperAccessor = termFlag(26, "<superaccessor>")
+ final val Scala2SuperAccessor = termFlag(26, "<superaccessor>")
/** An unpickled Scala 2.x class */
final val Scala2x = typeFlag(26, "<scala-2.x>")
- final val SuperAccessorOrScala2x = SuperAccessor.toCommonFlags
+ final val SuperAccessorOrScala2x = Scala2x.toCommonFlags
/** A method that has default params */
final val DefaultParameterized = termFlag(27, "<defaultparam>")
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index d8497f39d..8a9b68093 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -427,10 +427,8 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
val rhsIsEmpty = noRhs(end)
if (!rhsIsEmpty) skipTree()
val (givenFlags, annots, privateWithin) = readModifiers(end)
- val nameFlags =
- (if (name.is(NameExtractors.SuperAccessorName)) SuperAccessor else EmptyFlags)
pickling.println(i"creating symbol $name at $start with flags $givenFlags")
- val flags = normalizeFlags(tag, givenFlags | nameFlags, name, isAbsType, rhsIsEmpty)
+ val flags = normalizeFlags(tag, givenFlags, name, isAbsType, rhsIsEmpty)
def adjustIfModule(completer: LazyType) =
if (flags is Module) ctx.adjustModuleCompleter(completer, name) else completer
val sym =
diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala
index 773c6760e..2a789dca9 100644
--- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala
+++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala
@@ -224,7 +224,7 @@ object PickleBuffer {
DEFAULTPARAM -> (DefaultParameterized, Trait),
BRIDGE -> Bridge,
ACCESSOR -> Accessor,
- SUPERACCESSOR -> SuperAccessor,
+ SUPERACCESSOR -> Scala2SuperAccessor,
PARAMACCESSOR -> ParamAccessor,
MODULEVAR -> Scala2ModuleVar,
LAZY -> Lazy,
diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
index aed0e97f1..976eb5df4 100644
--- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
@@ -18,6 +18,7 @@ import printing.Printer
import io.AbstractFile
import util.common._
import typer.Checking.checkNonCyclic
+import transform.SymUtils._
import PickleBuffer._
import PickleFormat._
import Decorators._
@@ -441,7 +442,10 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
name = name.unmangleExpandedName
flags = flags &~ Scala2ExpandedName
}
- if (flags is SuperAccessor) name = name.asTermName.unmangleSuperName
+ if (flags is Scala2SuperAccessor) {
+ name = name.asTermName.unmangleSuperName
+ flags = flags &~ Scala2SuperAccessor
+ }
def isClassRoot = (name == classRoot.name) && (owner == classRoot.owner) && !(flags is ModuleClass)
def isModuleClassRoot = (name == moduleClassRoot.name) && (owner == moduleClassRoot.owner) && (flags is Module)
@@ -555,9 +559,9 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
else tp1
if (denot.isConstructor) addConstructorTypeParams(denot)
if (atEnd) {
- assert(!(denot is SuperAccessor), denot)
+ assert(!denot.isSuperAccessor, denot)
} else {
- assert(denot is (SuperAccessor | ParamAccessor), denot)
+ assert(denot.is(ParamAccessor) || denot.isSuperAccessor, denot)
def disambiguate(alt: Symbol) = { // !!! DEBUG
ctx.debugTraceIndented(s"disambiguating ${denot.info} =:= ${denot.owner.thisType.memberInfo(alt)} ${denot.owner}") {
denot.info matches denot.owner.thisType.memberInfo(alt)
diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
index 8d704f9a2..324aecdf0 100644
--- a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
+++ b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
@@ -7,6 +7,7 @@ import Annotations._, Contexts._, Flags._, Phases._, Trees._, Types._, Symbols._
import Names._, NameOps._, StdNames._
import typer.Inliner
import typer.ErrorReporting.cyclicErrorMsg
+import transform.SymUtils._
import dotty.tools.io.Path
import java.io.PrintWriter
@@ -539,7 +540,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
val abs = sym.is(Abstract) || sym.is(Deferred) || absOver
val over = sym.is(Override) || absOver
new api.Modifiers(abs, over, sym.is(Final), sym.is(Sealed),
- sym.is(Implicit), sym.is(Lazy), sym.is(Macro), sym.is(SuperAccessor))
+ sym.is(Implicit), sym.is(Lazy), sym.is(Macro), sym.isSuperAccessor)
}
def apiAnnotations(s: Symbol): List[api.Annotation] = {
diff --git a/compiler/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala b/compiler/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala
index 594d85bfa..fa79d995c 100644
--- a/compiler/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala
+++ b/compiler/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala
@@ -92,7 +92,7 @@ class AugmentScala2Traits extends MiniPhaseTransform with IdentityDenotTransform
traitSetter(sym.asTerm).enteredAfter(thisTransform)
if ((sym.is(PrivateAccessor) && !sym.name.is(ExpandedName) &&
(sym.isGetter || sym.isSetter)) // strangely, Scala 2 fields are also methods that have Accessor set.
- || sym.is(SuperAccessor)) // scala2 superaccessors are pickled as private, but are compiled as public expanded
+ || sym.isSuperAccessor) // scala2 superaccessors are pickled as private, but are compiled as public expanded
sym.ensureNotPrivate.installAfter(thisTransform)
}
ctx.log(i"Scala2x trait decls of $mixin = ${mixin.info.decls.toList.map(_.showDcl)}%\n %")
diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala
index 7b15b7e54..f63cba3f1 100644
--- a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala
@@ -38,7 +38,7 @@ class ExpandSAMs extends MiniPhaseTransform { thisTransformer =>
case tpe @ SAMType(_) if isPlatformSam(tpe.classSymbol.asClass) =>
tree
case tpe =>
- val Seq(samDenot) = tpe.abstractTermMembers.filter(!_.symbol.is(SuperAccessor))
+ val Seq(samDenot) = tpe.abstractTermMembers.filter(!_.symbol.isSuperAccessor)
cpy.Block(tree)(stats,
AnonClass(tpe :: Nil, fn.symbol.asTerm :: Nil, samDenot.symbol.asTerm.name :: Nil))
}
diff --git a/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala b/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
index 9e22a6b46..1df10cac2 100644
--- a/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
@@ -60,7 +60,7 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th
import ops._
def superAccessors(mixin: ClassSymbol): List[Tree] =
- for (superAcc <- mixin.info.decls.filter(_ is SuperAccessor).toList)
+ for (superAcc <- mixin.info.decls.filter(_.isSuperAccessor).toList)
yield polyDefDef(implementation(superAcc.asTerm), forwarder(rebindSuper(cls, superAcc)))
def methodOverrides(mixin: ClassSymbol): List[Tree] =
@@ -74,7 +74,7 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th
override def transformDefDef(ddef: DefDef)(implicit ctx: Context, info: TransformerInfo) = {
val meth = ddef.symbol.asTerm
- if (meth.is(SuperAccessor, butNot = Deferred)) {
+ if (meth.isSuperAccessor && !meth.is(Deferred)) {
assert(ddef.rhs.isEmpty)
val cls = meth.owner.asClass
val ops = new MixinOps(cls, thisTransform)
diff --git a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala
index 32923f0f5..bae1b897e 100644
--- a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala
+++ b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala
@@ -81,7 +81,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) {
ctx.debuglog(s"add super acc ${sym.showLocated} to $clazz")
val deferredOrPrivate = if (clazz is Trait) Deferred else Private
val acc = ctx.newSymbol(
- clazz, superName, SuperAccessor | Artifact | Method | deferredOrPrivate,
+ clazz, superName, Artifact | Method | deferredOrPrivate,
superInfo, coord = sym.coord).enteredAfter(thisTransformer)
// Diagnostic for SI-7091
if (!accDefs.contains(clazz))
diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
index f6ff539fe..1b3018d9b 100644
--- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
+++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
@@ -55,6 +55,8 @@ class SymUtils(val self: Symbol) extends AnyVal {
def isAliasPreferred(implicit ctx: Context) =
self.is(AliasPreferred) || self.name.is(ExpandedName)
+ def isSuperAccessor(implicit ctx: Context) = self.name.is(SuperAccessorName)
+
/** If this is a constructor, its owner: otherwise this. */
final def skipConstructor(implicit ctx: Context): Symbol =
if (self.isConstructor) self.owner else self
diff --git a/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala b/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala
index b16d05644..b398c2767 100644
--- a/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala
@@ -8,6 +8,7 @@ import SymDenotations._
import Contexts._
import Flags._
import StdNames._
+import SymUtils._
/** Methods that apply to user-defined value classes */
object ValueClasses {
@@ -24,7 +25,7 @@ object ValueClasses {
d.isRealMethod &&
isDerivedValueClass(d.owner) &&
!d.isConstructor &&
- !d.is(SuperAccessor) &&
+ !d.isSuperAccessor &&
!d.is(Macro)
/** The member that of a derived value class that unboxes it. */
diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
index d61f5fa68..49bc24c80 100644
--- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
+++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
@@ -405,7 +405,7 @@ object RefChecks {
def ignoreDeferred(member: SingleDenotation) =
member.isType ||
- member.symbol.is(SuperAccessor) || // not yet synthesized
+ member.symbol.isSuperAccessor || // not yet synthesized
member.symbol.is(JavaDefined) && hasJavaErasedOverriding(member.symbol)
// 2. Check that only abstract classes have deferred members