aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-09 16:19:45 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-09 16:24:30 +0100
commit9d924441fdeab3bbe0c6cca8c1ecce6ecf64a608 (patch)
tree7bfd0515195a83016bd03cbac0e54d49499e30aa /src/dotty
parent6a6bc87871e1c6382da7023ab64c69391366c808 (diff)
downloaddotty-9d924441fdeab3bbe0c6cca8c1ecce6ecf64a608.tar.gz
dotty-9d924441fdeab3bbe0c6cca8c1ecce6ecf64a608.tar.bz2
dotty-9d924441fdeab3bbe0c6cca8c1ecce6ecf64a608.zip
Making completer take an implicit context
As a first step, we make the complete method in LazyType take an implicit context parameter. This requires a fairly large propagation of implicit contexts. The implicit parameter is ignored for classes inheriting from CompleteInCreationContext (which until now are all completers). The next step will be to make the complete methods of selective lazy types take the current context, rather than the creation context.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala8
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala35
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala3
-rw-r--r--src/dotty/tools/dotc/core/Scopes.scala4
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala87
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala4
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala4
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala8
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala4
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala8
11 files changed, 97 insertions, 71 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index b5ec98343..8c6e8d72c 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -37,8 +37,8 @@ class Definitions(implicit ctx: Context) {
newTypeParam(cls, suffix.toTypeName.expandedName(cls), ExpandedName, scope)
private def specialPolyClass(name: TypeName, paramFlags: FlagSet, parentConstrs: Type*): ClassSymbol = {
- val completer = new LazyType {
- def complete(denot: SymDenotation): Unit = {
+ val completer = new LazyType with CompleteInCreationContext {
+ def completeInCreationContext(denot: SymDenotation): Unit = {
val cls = denot.asClass.classSymbol
val paramDecls = newScope
val typeParam = newSyntheticTypeParam(cls, paramDecls, paramFlags)
@@ -368,8 +368,8 @@ class Definitions(implicit ctx: Context) {
case 1 => EmptyFlags
}
- val completer = new LazyType {
- def complete(denot: SymDenotation): Unit = {
+ val completer = new LazyType with CompleteInCreationContext {
+ def completeInCreationContext(denot: SymDenotation): Unit = {
val cls = denot.asClass.classSymbol
val paramDecls = newScope
for ((v, i) <- vcs.zipWithIndex)
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index bc7545abd..2ad193970 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -98,7 +98,12 @@ object Denotations {
def symbol: Symbol
/** The type info of the denotation, exists only for non-overloaded denotations */
- def info: Type
+ def info(implicit ctx: Context): Type
+
+ /** The type info, or, if this is a SymDenotation where the symbol
+ * is not yet completed, the completer
+ */
+ def infoOrCompleter: Type
/** The period during which this denotation is valid. */
def validFor: Period
@@ -315,7 +320,8 @@ object Denotations {
*/
case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation {
final def symbol: Symbol = NoSymbol
- final def info = multiHasNot("info")
+ final def infoOrCompleter = multiHasNot("info")
+ final def info(implicit ctx: Context) = infoOrCompleter
final def validFor = denot1.validFor & denot2.validFor
final def isType = false
def signature(implicit ctx: Context) = multiHasNot("signature")
@@ -356,7 +362,6 @@ object Denotations {
def hasUniqueSym: Boolean
protected def newLikeThis(symbol: Symbol, info: Type): SingleDenotation
- def isType = info.isInstanceOf[TypeType]
final def signature(implicit ctx: Context): Signature = {
if (isType) Signature.NotAMethod // don't force info if this is a type SymDenotation
else info match {
@@ -371,7 +376,7 @@ object Denotations {
}
}
- def derivedSingleDenotation(symbol: Symbol, info: Type): SingleDenotation =
+ def derivedSingleDenotation(symbol: Symbol, info: Type)(implicit ctx: Context): SingleDenotation =
if ((symbol eq this.symbol) && (info eq this.info)) this
else newLikeThis(symbol, info)
@@ -535,7 +540,7 @@ object Denotations {
override def toString =
if (symbol == NoSymbol) symbol.toString
- else s"<SingleDenotation of type $info>"
+ else s"<SingleDenotation of type $infoOrCompleter>"
// ------ PreDenotation ops ----------------------------------------------
@@ -571,10 +576,16 @@ object Denotations {
}
}
+ abstract class NonSymSingleDenotation extends SingleDenotation {
+ def infoOrCompleter: Type
+ def info(implicit ctx: Context) = infoOrCompleter
+ def isType = infoOrCompleter.isInstanceOf[TypeType]
+ }
+
class UniqueRefDenotation(
val symbol: Symbol,
- val info: Type,
- initValidFor: Period) extends SingleDenotation {
+ val infoOrCompleter: Type,
+ initValidFor: Period) extends NonSymSingleDenotation {
validFor = initValidFor
override def hasUniqueSym: Boolean = true
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
@@ -582,18 +593,18 @@ object Denotations {
class JointRefDenotation(
val symbol: Symbol,
- val info: Type,
- initValidFor: Period) extends SingleDenotation {
+ val infoOrCompleter: Type,
+ initValidFor: Period) extends NonSymSingleDenotation {
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 SingleDenotation {
+ class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation {
override def exists = false
override def hasUniqueSym = false
- val symbol = NoSymbol
- val info = NoType
+ def symbol = NoSymbol
+ def infoOrCompleter = NoType
validFor = Period.allInRun(ctx.runId)
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = this
}
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index d7d30f438..ab17c7176 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -175,6 +175,9 @@ object Flags {
/** The empty flag set */
final val EmptyFlags = FlagSet(0)
+ /** The undefined flag set */
+ final val UndefinedFlags = FlagSet(~KINDFLAGS)
+
// Available flags:
/** Labeled with `private` modifier */
diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala
index cdc596e2b..a20433b1f 100644
--- a/src/dotty/tools/dotc/core/Scopes.scala
+++ b/src/dotty/tools/dotc/core/Scopes.scala
@@ -344,8 +344,8 @@ object Scopes {
def scopeTransform(owner: Symbol)(op: => MutableScope): MutableScope = op
val selectAll: SymDenotation => Boolean = alwaysTrue
- val selectPrivate: SymDenotation => Boolean = d => (d is Flags.Private)
- val selectNonPrivate: SymDenotation => Boolean = d => !(d is Flags.Private)
+ val selectPrivate: SymDenotation => Boolean = d => (d.flagsUNSAFE is Flags.Private)
+ val selectNonPrivate: SymDenotation => Boolean = d => !(d.flagsUNSAFE is Flags.Private)
/** The empty scope (immutable).
*/
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 7b9d4cd48..3169efea0 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -71,7 +71,7 @@ object SymDenotations {
def owner: Symbol = ownerIfExists
/** The flag set */
- final def flags: FlagSet = { ensureCompleted(); myFlags }
+ final def flags(implicit ctx: Context): FlagSet = { ensureCompleted(); myFlags }
/** The flag set without forcing symbol completion.
* Should be used only for printing.
@@ -92,42 +92,45 @@ object SymDenotations {
final def resetFlag(flags: FlagSet): Unit = { myFlags &~= flags }
/** Has this denotation one of the flags in `fs` set? */
- final def is(fs: FlagSet) = {
+ final def is(fs: FlagSet)(implicit ctx: Context) = {
(if (fs <= FromStartFlags) 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) =
+ final def is(fs: FlagSet, butNot: FlagSet)(implicit ctx: Context) =
(if (fs <= FromStartFlags && butNot <= FromStartFlags) myFlags else flags) is (fs, butNot)
/** Has this denotation all of the flags in `fs` set? */
- final def is(fs: FlagConjunction) =
+ final def is(fs: FlagConjunction)(implicit ctx: Context) =
(if (fs <= FromStartFlags) 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) =
+ final def is(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context) =
(if (fs <= FromStartFlags && butNot <= FromStartFlags) 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: Type = myInfo match {
+ final def info(implicit ctx: Context): Type = myInfo match {
case myInfo: LazyType => completeFrom(myInfo); info
case _ => myInfo
}
+ /** The type info, or, if symbol is not yet completed, the completer */
+ final def infoOrCompleter = myInfo
+
/** Optionally, the info if it is completed */
final def unforcedInfo: Option[Type] = myInfo match {
case myInfo: LazyType => None
case _ => Some(myInfo)
}
- private def completeFrom(completer: LazyType): Unit = {
+ private def completeFrom(completer: LazyType)(implicit ctx: Context): Unit = {
if (myFlags is Touched) throw new CyclicReference(this)
myFlags |= Touched
@@ -151,19 +154,19 @@ object SymDenotations {
}
/** The name, except if this is a module class, strip the module class suffix */
- def effectiveName =
+ def effectiveName(implicit ctx: Context) =
if (this is ModuleClass) name.stripModuleClassSuffix else name
/** The privateWithin boundary, NoSymbol if no boundary is given.
*/
- final def privateWithin: Symbol = { ensureCompleted(); myPrivateWithin }
+ final def privateWithin(implicit ctx: Context): Symbol = { ensureCompleted(); myPrivateWithin }
/** Set privateWithin. */
protected[core] final def privateWithin_=(sym: Symbol): Unit =
myPrivateWithin = sym
/** The annotations of this denotation */
- final def annotations: List[Annotation] = {
+ final def annotations(implicit ctx: Context): List[Annotation] = {
ensureCompleted(); myAnnotations
}
@@ -195,7 +198,7 @@ object SymDenotations {
final def completer: LazyType = myInfo.asInstanceOf[LazyType]
/** Make sure this denotation is completed */
- final def ensureCompleted(): Unit = info
+ final def ensureCompleted()(implicit ctx: Context): Unit = info
/** The symbols defined in this class or object.
*/
@@ -221,7 +224,7 @@ object SymDenotations {
// ------ Names ----------------------------------------------
/** The name with which the denoting symbol was created */
- final def originalName = {
+ final def originalName(implicit ctx: Context) = {
val d = initial.asSymDenotation
if (d is ExpandedName) d.name.unexpandedName() else d.name // !!!DEBUG, was: effectiveName
}
@@ -292,10 +295,10 @@ object SymDenotations {
}
/** Is this symbol an abstract type? */
- final def isAbstractType = isType && (this is Deferred)
+ final def isAbstractType(implicit ctx: Context) = isType && (this is Deferred)
/** Is this symbol an alias type? */
- final def isAliasType = isAbstractOrAliasType && !(this is Deferred)
+ final def isAliasType(implicit ctx: Context) = isAbstractOrAliasType && !(this is Deferred)
/** Is this symbol an abstract or alias type? */
final def isAbstractOrAliasType = isType & !isClass
@@ -346,13 +349,13 @@ object SymDenotations {
}
/** Is this a user defined "def" method? Excluded are accessors. */
- final def isSourceMethod = this is (Method, butNot = Accessor)
+ final def isSourceMethod(implicit ctx: Context) = this is (Method, butNot = Accessor)
/** Is this a setter? */
- final def isGetter = (this is Accessor) && !originalName.isSetterName
+ final def isGetter(implicit ctx: Context) = (this is Accessor) && !originalName.isSetterName
/** Is this a setter? */
- final def isSetter = (this is Accessor) && originalName.isSetterName
+ final def isSetter(implicit ctx: Context) = (this is Accessor) && originalName.isSetterName
/** is this the constructor of a class? */
final def isClassConstructor = name == nme.CONSTRUCTOR
@@ -679,18 +682,18 @@ object SymDenotations {
/** The variance of this type parameter or type member as an Int, with
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
*/
- final def variance: Int =
+ final def variance(implicit ctx: Context): Int =
if (this is Covariant) 1
else if (this is Contravariant) -1
else 0
override def toString = {
val kindString =
- if (this is ModuleClass) "module class"
+ if (myFlags is ModuleClass) "module class"
else if (isClass) "class"
else if (isType) "type"
- else if (this is Module) "module"
- else if (this is Method) "method"
+ else if (myFlags is Module) "module"
+ else if (myFlags is Method) "method"
else "val"
s"$kindString $name"
}
@@ -706,13 +709,17 @@ object SymDenotations {
symbol: Symbol = this.symbol,
owner: Symbol = this.owner,
name: Name = this.name,
- initFlags: FlagSet = this.flags,
- info: Type = this.info,
- privateWithin: Symbol = this.privateWithin,
- annotations: List[Annotation] = this.annotations)(implicit ctx: Context) =
- {
- val d = ctx.SymDenotation(symbol, owner, name, initFlags, info, privateWithin)
- d.annotations = annotations
+ initFlags: FlagSet = UndefinedFlags,
+ info: Type = null,
+ privateWithin: Symbol = null,
+ annotations: List[Annotation] = null)(implicit ctx: Context) =
+ { // simulate default parameters, while also passing implicit context ctx to the default values
+ val initFlags1 = if (initFlags != UndefinedFlags) initFlags else this.flags
+ val info1 = if (info != null) info else this.info
+ val privateWithin1 = if (privateWithin != null) privateWithin else this.privateWithin
+ val annotations1 = if (annotations != null) annotations else this.annotations
+ val d = ctx.SymDenotation(symbol, owner, name, initFlags1, info1, privateWithin1)
+ d.annotations = annotations1
d
}
}
@@ -751,7 +758,7 @@ object SymDenotations {
myTypeParams
}
- private def myClassParents: List[TypeRef] = info match {
+ private def myClassParents(implicit ctx: Context): List[TypeRef] = info match {
case classInfo: ClassInfo => classInfo.myClassParents
case _ => Nil
}
@@ -1194,7 +1201,7 @@ object SymDenotations {
with ((TermSymbol, ClassSymbol) => LazyType) { self =>
/** Sets all missing fields of given denotation */
- def complete(denot: SymDenotation): Unit
+ def complete(denot: SymDenotation)(implicit ctx: Context): Unit
def apply(sym: Symbol) = this
def apply(module: TermSymbol, modcls: ClassSymbol) = this
@@ -1207,7 +1214,7 @@ object SymDenotations {
* but provides fresh slots for scope/sourceModule/moduleClass
*/
def proxy: LazyType = new LazyType {
- override def complete(denot: SymDenotation) = self.complete(denot)
+ override def complete(denot: SymDenotation)(implicit ctx: Context) = self.complete(denot)
}
def decls: Scope = myDecls
@@ -1219,11 +1226,17 @@ object SymDenotations {
def withModuleClass(moduleClass: => Symbol): this.type = { myModuleClassFn = () => moduleClass; this }
}
+ trait CompleteInCreationContext extends LazyType {
+ def completeInCreationContext(denot: SymDenotation): Unit
+ final override def complete(denot: SymDenotation)(implicit ctx: Context) =
+ completeInCreationContext(denot)
+ }
+
val NoSymbolFn = () => NoSymbol
/** A missing completer */
class NoCompleter extends LazyType {
- def complete(denot: SymDenotation): Unit = unsupported("complete")
+ def complete(denot: SymDenotation)(implicit ctx: Context): Unit = unsupported("complete")
}
/** A lazy type for modules that points to the module class.
@@ -1232,8 +1245,8 @@ object SymDenotations {
* module class, followed by copying the relevant fields to the module.
*/
class ModuleCompleter(override val moduleClass: ClassSymbol)(implicit cctx: CondensedContext)
- extends LazyType {
- def complete(denot: SymDenotation): Unit = {
+ extends LazyType with CompleteInCreationContext {
+ def completeInCreationContext(denot: SymDenotation): Unit = {
val from = moduleClass.denot.asClass
denot.setFlag(from.flags.toTermFlags & RetainedModuleValFlags)
denot.annotations = from.annotations filter (_.appliesToModule)
@@ -1247,9 +1260,9 @@ object SymDenotations {
}
/** A completer for missing references */
- class StubInfo()(implicit cctx: CondensedContext) extends LazyType {
+ class StubInfo()(implicit cctx: CondensedContext) extends LazyType with CompleteInCreationContext {
- def initializeToDefaults(denot: SymDenotation) = {
+ def initializeToDefaults(denot: SymDenotation)(implicit ctx: Context) = {
denot.info = denot match {
case denot: ClassDenotation =>
ClassInfo(denot.owner.thisType, denot.classSymbol, Nil, EmptyScope)
@@ -1259,7 +1272,7 @@ object SymDenotations {
denot.privateWithin = NoSymbol
}
- def complete(denot: SymDenotation): Unit = {
+ def completeInCreationContext(denot: SymDenotation): Unit = {
val sym = denot.symbol
val file = sym.associatedFile
val (location, src) =
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index d88e84ff7..d1eb2872c 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -173,7 +173,7 @@ class SymbolLoaders {
/** A lazy type that completes itself by calling parameter doComplete.
* Any linked modules/classes or module classes are also initialized.
*/
-abstract class SymbolLoader extends LazyType {
+abstract class SymbolLoader extends LazyType with CompleteInCreationContext {
implicit val cctx: CondensedContext
/** Load source or class file for `root`, return */
@@ -186,7 +186,7 @@ abstract class SymbolLoader extends LazyType {
*/
def description: String
- override def complete(root: SymDenotation): Unit = {
+ override def completeInCreationContext(root: SymDenotation): Unit = {
def signalError(ex: Exception): Unit = {
if (cctx.debug) ex.printStackTrace()
val msg = ex.getMessage()
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 4e0a857a3..deb906417 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -87,8 +87,8 @@ trait TypeOps { this: Context =>
}
private def enterArgBinding(formal: Symbol, info: Type, cls: ClassSymbol, decls: Scope) = {
- val lazyInfo = new LazyType { // needed so we do not force `formal`.
- def complete(denot: SymDenotation): Unit = {
+ val lazyInfo = new LazyType with CompleteInCreationContext { // needed so we do not force `formal`.
+ def completeInCreationContext(denot: SymDenotation): Unit = {
denot setFlag formal.flags & RetainedTypeArgFlags
denot.info = info
}
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index 5edddc396..8745593f4 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -163,9 +163,9 @@ class ClassfileParser(
skipAttributes
}
- val memberCompleter = new LazyType {
+ val memberCompleter = new LazyType with CompleteInCreationContext {
- def complete(denot: SymDenotation): Unit = {
+ def completeInCreationContext(denot: SymDenotation): Unit = {
val oldbp = in.bp
try {
in.bp = denot.symbol.coord.toIndex
@@ -337,8 +337,8 @@ class ClassfileParser(
var tparams = classTParams
- def typeParamCompleter(start: Int) = new LazyType {
- def complete(denot: SymDenotation): Unit = {
+ def typeParamCompleter(start: Int) = new LazyType with CompleteInCreationContext {
+ def completeInCreationContext(denot: SymDenotation): Unit = {
val savedIndex = index
try {
index = start
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 17d4e874a..706eb477e 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -490,7 +490,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
})
}
- class LocalUnpickler extends LazyType {
+ class LocalUnpickler extends LazyType with CompleteInCreationContext {
def parseToCompletion(denot: SymDenotation) = {
val tag = readByte()
val end = readNat() + readIndex
@@ -533,7 +533,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
// println(s"unpickled ${denot.debugString}, info = ${denot.info}") !!! DEBUG
}
def startCoord(denot: SymDenotation): Coord = denot.symbol.coord
- def complete(denot: SymDenotation): Unit = try {
+ def completeInCreationContext(denot: SymDenotation): Unit = try {
atReadPos(startCoord(denot).toIndex, () => parseToCompletion(denot))
} catch {
case ex: RuntimeException => handleRuntimeException(ex)
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index ba896c4d3..df00280ac 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -441,9 +441,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
override def toText(sym: Symbol): Text = {
if (sym.name == nme.IMPORT) {
- val info = if (sym.isCompleted) sym.info else sym.completer
def importString(tree: untpd.Tree) = s"import ${tree.show}"
- info match {
+ sym.infoOrCompleter match {
case info: Namer#Completer => return importString(info.original)
case info: ImportType => return importString(info.expr)
case _ =>
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index e79bd32c1..4d184c17b 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -274,7 +274,7 @@ class Namer { typer: Typer =>
}
/** For all class definitions `stat` in `xstats`: If the companion class if not also defined
- * in `xstats`, invalidate it by setting its info to NoType.
+ * in `xstats`, invalidate it by setting its info to NoType.
*/
def invalidateCompanions(pkg: Symbol, xstats: List[untpd.Tree])(implicit ctx: Context): Unit = {
val definedNames = xstats collect { case stat: NameTree => stat.name }
@@ -350,7 +350,7 @@ class Namer { typer: Typer =>
}
/** The completer of a symbol defined by a member def or import (except ClassSymbols) */
- class Completer(val original: Tree)(implicit ctx: Context) extends LazyType {
+ class Completer(val original: Tree)(implicit ctx: Context) extends LazyType with CompleteInCreationContext {
protected def localContext(owner: Symbol) = ctx.fresh.withOwner(owner).withTree(original)
@@ -376,7 +376,7 @@ class Namer { typer: Typer =>
}
}
- def complete(denot: SymDenotation): Unit =
+ override def completeInCreationContext(denot: SymDenotation): Unit =
denot.info = typeSig(denot.symbol)
}
@@ -396,7 +396,7 @@ class Namer { typer: Typer =>
def init() = index(params)
/** The type signature of a ClassDef with given symbol */
- override def complete(denot: SymDenotation): Unit = {
+ override def completeInCreationContext(denot: SymDenotation): Unit = {
/** The type of a parent constructor. Types constructor arguments
* only if parent type contains uninstantiated type parameters.