From 50fc1b74c6228b07cf82783db8d8128954d7b6a1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 9 Oct 2017 14:39:12 +0200 Subject: [PATCH 1/2] Remove unused designator methods --- compiler/src/dotty/tools/dotc/core/Designators.scala | 7 ++----- compiler/src/dotty/tools/dotc/core/Names.scala | 1 - compiler/src/dotty/tools/dotc/core/Symbols.scala | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Designators.scala b/compiler/src/dotty/tools/dotc/core/Designators.scala index 52c20bb0e3c4..210b3fc36d06 100644 --- a/compiler/src/dotty/tools/dotc/core/Designators.scala +++ b/compiler/src/dotty/tools/dotc/core/Designators.scala @@ -18,14 +18,11 @@ object Designators { type ThisName <: Name /** Classifiers and casts, to be overridden in implemetations */ - def isName: Boolean = false - def isSymbol: Boolean = false - def isTerm(implicit ctx: Context) = false def isType(implicit ctx: Context) = false - def asTerm(implicit ctx: Context): TermDesignator = unsupported("asTerm") - def asType(implicit ctx: Context): TypeDesignator = unsupported("asType") + def asTerm(implicit ctx: Context): TermDesignator + def asType(implicit ctx: Context): TypeDesignator def withNameSpace(space: NameSpace)(implicit ctx: Context): Designator { type ThisName = self.ThisName } = if (space == noNameSpace) this diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala index 17a64f471084..77435dc672e5 100644 --- a/compiler/src/dotty/tools/dotc/core/Names.scala +++ b/compiler/src/dotty/tools/dotc/core/Names.scala @@ -155,7 +155,6 @@ object Names { def endsWith(str: String): Boolean = lastPart.endsWith(str) /** Designator overrides */ - override def isName = true override def isTerm(implicit ctx: Context) = isTermName override def isType(implicit ctx: Context) = isTypeName override def asTerm(implicit ctx: Context) = asTermName diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 77da1f5f16f7..2e3661a52039 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -444,7 +444,6 @@ object Symbols { lastDenot.validFor.runId == ctx.runId || ctx.stillValid(lastDenot) /** Designator overrides */ - final override def isSymbol = true final override def isTerm(implicit ctx: Context): Boolean = (if (defRunId == ctx.runId) lastDenot else denot).isTerm final override def isType(implicit ctx: Context): Boolean = From f07c25ae86627c1ea7dd4f1850fb2382edb7d4a4 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 9 Oct 2017 14:41:42 +0200 Subject: [PATCH 2/2] Use descriptive name for SelfInfo type --- compiler/src/dotty/tools/dotc/core/Types.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 54c3113ddfe0..26d5741c67e5 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3373,6 +3373,8 @@ object Types { // ------ ClassInfo, Type Bounds ------------------------------------------------------------ + type TypeOrSymbol = AnyRef /* should be: Type | Symbol */ + /** Roughly: the info of a class during a period. * @param prefix The prefix on which parents, decls, and selfType need to be rebased. * @param cls The class symbol. @@ -3389,7 +3391,7 @@ object Types { cls: ClassSymbol, classParents: List[Type], decls: Scope, - selfInfo: DotClass /* should be: Type | Symbol */) extends CachedGroundType with TypeType { + selfInfo: TypeOrSymbol) extends CachedGroundType with TypeType { private[this] var selfTypeCache: Type = null private[this] var appliedRefCache: Type = null @@ -3437,7 +3439,7 @@ object Types { if (prefix eq this.prefix) this else ClassInfo(prefix, cls, classParents, decls, selfInfo) - def derivedClassInfo(prefix: Type = this.prefix, classParents: List[Type] = this.classParents, decls: Scope = this.decls, selfInfo: DotClass = this.selfInfo)(implicit ctx: Context) = + def derivedClassInfo(prefix: Type = this.prefix, classParents: List[Type] = this.classParents, decls: Scope = this.decls, selfInfo: TypeOrSymbol = this.selfInfo)(implicit ctx: Context) = if ((prefix eq this.prefix) && (classParents eq this.classParents) && (decls eq this.decls) && (selfInfo eq this.selfInfo)) this else ClassInfo(prefix, cls, classParents, decls, selfInfo) @@ -3456,11 +3458,11 @@ object Types { override def toString = s"ClassInfo($prefix, $cls, $classParents)" } - class CachedClassInfo(prefix: Type, cls: ClassSymbol, classParents: List[Type], decls: Scope, selfInfo: DotClass) + class CachedClassInfo(prefix: Type, cls: ClassSymbol, classParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol) extends ClassInfo(prefix, cls, classParents, decls, selfInfo) /** A class for temporary class infos where `parents` are not yet known */ - final class TempClassInfo(prefix: Type, cls: ClassSymbol, decls: Scope, selfInfo: DotClass) + final class TempClassInfo(prefix: Type, cls: ClassSymbol, decls: Scope, selfInfo: TypeOrSymbol) extends CachedClassInfo(prefix, cls, Nil, decls, selfInfo) { /** Install classinfo with known parents in `denot` s */ @@ -3475,7 +3477,7 @@ object Types { } object ClassInfo { - def apply(prefix: Type, cls: ClassSymbol, classParents: List[Type], decls: Scope, selfInfo: DotClass = NoType)(implicit ctx: Context) = + def apply(prefix: Type, cls: ClassSymbol, classParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol = NoType)(implicit ctx: Context) = unique(new CachedClassInfo(prefix, cls, classParents, decls, selfInfo)) }