Skip to content

Remove PreName add (almost) all other implicit conversions #4077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import config.Config
import util.common._
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM

import collection.mutable.ListBuffer
import Decorators.SymbolIteratorDecorator
import SymDenotations.LazyType

/** Denotations represent the meaning of symbols and named types.
* The following diagram shows how the principal types of denotations
Expand Down Expand Up @@ -171,12 +172,19 @@ object Denotations {
*
* @param symbol The referencing symbol, or NoSymbol is none exists
*/
abstract class Denotation(val symbol: Symbol) extends PreDenotation with printing.Showable {

abstract class Denotation(val symbol: Symbol, protected var myInfo: Type) extends PreDenotation with printing.Showable {
type AsSeenFromResult <: Denotation

/** The type info of the denotation, exists only for non-overloaded denotations */
def info(implicit ctx: Context): Type
/** The type info.
* The info is an instance of TypeType iff this is a type denotation
* Uncompleted denotations set myInfo to a LazyType.
*/
final def info(implicit ctx: Context): Type = {
def completeInfo = { // Written this way so that `info` is small enough to be inlined
this.asInstanceOf[SymDenotation].completeFrom(myInfo.asInstanceOf[LazyType]); info
}
if (myInfo.isInstanceOf[LazyType]) completeInfo else myInfo
}

/** The type info, or, if this is a SymDenotation where the symbol
* is not yet completed, the completer
Expand Down Expand Up @@ -646,7 +654,7 @@ object Denotations {
}

/** A non-overloaded denotation */
abstract class SingleDenotation(symbol: Symbol) extends Denotation(symbol) {
abstract class SingleDenotation(symbol: Symbol, initInfo: Type) extends Denotation(symbol, initInfo) {
protected def newLikeThis(symbol: Symbol, info: Type): SingleDenotation

final def name(implicit ctx: Context): Name = symbol.name
Expand Down Expand Up @@ -1076,34 +1084,32 @@ object Denotations {
}
}

abstract class NonSymSingleDenotation(symbol: Symbol) extends SingleDenotation(symbol) {
def infoOrCompleter: Type
def info(implicit ctx: Context) = infoOrCompleter
abstract class NonSymSingleDenotation(symbol: Symbol, initInfo: Type) extends SingleDenotation(symbol, initInfo) {
def infoOrCompleter: Type = initInfo
def isType = infoOrCompleter.isInstanceOf[TypeType]
}

class UniqueRefDenotation(
symbol: Symbol,
val infoOrCompleter: Type,
initValidFor: Period) extends NonSymSingleDenotation(symbol) {
initInfo: Type,
initValidFor: Period) extends NonSymSingleDenotation(symbol, initInfo) {
validFor = initValidFor
override def hasUniqueSym: Boolean = true
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
}

class JointRefDenotation(
symbol: Symbol,
val infoOrCompleter: Type,
initValidFor: Period) extends NonSymSingleDenotation(symbol) {
initInfo: Type,
initValidFor: Period) extends NonSymSingleDenotation(symbol, initInfo) {
validFor = initValidFor
override def hasUniqueSym = false
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new JointRefDenotation(s, i, validFor)
}

class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation(NoSymbol) {
class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation(NoSymbol, NoType) {
override def exists = false
override def hasUniqueSym = false
def infoOrCompleter = NoType
validFor = Period.allInRun(ctx.runId)
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = this
}
Expand Down Expand Up @@ -1185,9 +1191,9 @@ object Denotations {

/** An overloaded denotation consisting of the alternatives of both given denotations.
*/
case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation(NoSymbol) with MultiPreDenotation {
case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation(NoSymbol, NoType) with MultiPreDenotation {
final def infoOrCompleter = multiHasNot("info")
final def info(implicit ctx: Context) = infoOrCompleter
// final def info(implicit ctx: Context) = infoOrCompleter
final def validFor = denot1.validFor & denot2.validFor
final def isType = false
final def hasUniqueSym = false
Expand Down
16 changes: 2 additions & 14 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object SymDenotations {
final val name: Name,
initFlags: FlagSet,
initInfo: Type,
initPrivateWithin: Symbol = NoSymbol) extends SingleDenotation(symbol) {
initPrivateWithin: Symbol = NoSymbol) extends SingleDenotation(symbol, initInfo) {

//assert(symbol.id != 4940, name)

Expand All @@ -142,7 +142,6 @@ object SymDenotations {
// ------ Getting and setting fields -----------------------------

private[this] var myFlags: FlagSet = adaptFlags(initFlags)
private[this] var myInfo: Type = initInfo
private[this] var myPrivateWithin: Symbol = initPrivateWithin
private[this] var myAnnotations: List[Annotation] = Nil

Expand Down Expand Up @@ -201,17 +200,6 @@ object SymDenotations {
final def is(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context) =
(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
* Uncompleted denotations set myInfo to a LazyType.
*/
final def info(implicit ctx: Context): Type = {
def completeInfo = { // Written this way so that `info` is small enough to be inlined
completeFrom(myInfo.asInstanceOf[LazyType]); info
}
if (myInfo.isInstanceOf[LazyType]) completeInfo else myInfo
}

/** The type info, or, if symbol is not yet completed, the completer */
final def infoOrCompleter = myInfo

Expand All @@ -221,7 +209,7 @@ object SymDenotations {
case _ => Some(myInfo)
}

private def completeFrom(completer: LazyType)(implicit ctx: Context): Unit =
final def completeFrom(completer: LazyType)(implicit ctx: Context): Unit =
if (Config.showCompletions) {
println(i"${" " * indent}completing ${if (isType) "type" else "val"} $name")
indent += 1
Expand Down