aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-02-01 15:00:03 +0100
committerMartin Odersky <odersky@gmail.com>2013-02-01 15:00:03 +0100
commit5610fe1abbb8e4cb005d644f37669f872327828b (patch)
treee8c1f9c7a18e1ea299c14d421fcd251f1c2a4dfc /src/dotty
parent4faeeceffdbc8dec9dd53bf299174a13d6bf87d0 (diff)
downloaddotty-5610fe1abbb8e4cb005d644f37669f872327828b.tar.gz
dotty-5610fe1abbb8e4cb005d644f37669f872327828b.tar.bz2
dotty-5610fe1abbb8e4cb005d644f37669f872327828b.zip
Refined completion, in particular for module symbols and made contexts explicit.
Made contexts in class constructors explicit (named initctx), so that we can better track where they are used. It's important that the context is not retained in the state of the object.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/Annotations.scala1
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala6
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala249
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala8
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala79
-rw-r--r--src/dotty/tools/dotc/core/Types.scala12
-rw-r--r--src/dotty/tools/io/Jar.scala2
8 files changed, 218 insertions, 141 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala
index ead92409e..71e747598 100644
--- a/src/dotty/tools/dotc/core/Annotations.scala
+++ b/src/dotty/tools/dotc/core/Annotations.scala
@@ -6,6 +6,7 @@ object Annotations {
abstract class Annotation {
def matches(cls: Symbol) = ???
+ def appliesToModule: Boolean = ???
}
} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 2e13aed47..2b725c8b4 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -31,15 +31,15 @@ class Definitions(implicit ctx: Context) {
lazy val ObjectClass = requiredClass("java.lang.Object")
lazy val AnyRefAlias: TypeSymbol = ctx.newAliasTypeSymbol(
ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor).entered
- lazy val AnyClass: ClassSymbol = ctx.newCompleteClassSymbol(
+ lazy val AnyClass: ClassSymbol = ctx.newClassSymbol(
ScalaPackageClass, tpnme.Any, Abstract, Nil).entered
lazy val AnyValClass: ClassSymbol = requiredClass("scala.AnyVal")
lazy val NotNullClass = requiredClass("scala.NotNull")
- lazy val NothingClass: ClassSymbol = ctx.newCompleteClassSymbol(
+ lazy val NothingClass: ClassSymbol = ctx.newClassSymbol(
ScalaPackageClass, tpnme.Nothing, UninstantiatableFlags, List(AnyType)).entered
- lazy val NullClass: ClassSymbol = ctx.newCompleteClassSymbol(
+ lazy val NullClass: ClassSymbol = ctx.newClassSymbol(
ScalaPackageClass, tpnme.Null, UninstantiatableFlags, List(AnyRefType)).entered
lazy val PredefModule = requiredModule("scala.Predef")
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index 0ebcc876e..cafc4495d 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -331,6 +331,8 @@ object Flags {
/** Flags representing access rights */
final val AccessFlags = Private | Protected | Local
+ final val ModuleFlags: FlagSet = ???
+
final val UninstantiatableFlags = Abstract | Final
/** These flags are enabled from phase 1 */
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index ea3ab36c5..0b61906b1 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -21,30 +21,30 @@ object SymDenotations {
def name: Name
+ def privateWithin: Symbol
+
def symbol: Symbol
def info: Type
- final def isLoaded = _privateWithin != null
- final def isCompleted = _annotations != null
+ // The following 4 members are overridden is instances of isLazy
+ def isLoaded = true
+ def isCompleted = true
+ protected[core] def tryLoad(): Unit = unsupported("tryLoad")
+ protected[core] def tryComplete(): Unit = unsupported("tryComplete")
+
final def ensureLoaded() = if (!isLoaded) tryLoad()
final def ensureCompleted() = if (!isCompleted) tryComplete()
- protected def tryLoad(): Unit
- protected def tryComplete(): Unit
private[this] var _flags: FlagSet = initFlags
def flags: FlagSet = { ensureLoaded(); _flags }
- def flags_=(flags: FlagSet): Unit = { _flags |= flags }
+ def flags_=(flags: FlagSet): Unit = { _flags = flags }
def setFlags(flags: FlagSet): Unit = { _flags |= flags }
def resetFlags(flags: FlagSet): Unit = { _flags &~= flags }
- private[this] var _privateWithin: Symbol = _
- def privateWithin: Symbol = { ensureLoaded(); _privateWithin }
- def privateWithin_=(sym: Symbol): Unit = { _privateWithin = sym }
-
- private[this] var _annotations: List[Annotation] = { ensureCompleted(); _annotations }
- def annotations: List[Annotation] = _annotations
+ private[this] var _annotations: List[Annotation] = Nil
+ def annotations: List[Annotation] = { ensureCompleted(); _annotations }
def annotations_=(annots: List[Annotation]): Unit = { _annotations = annots }
def hasAnnotation(cls: Symbol) = dropOtherAnnotations(annotations, cls).nonEmpty
@@ -105,11 +105,18 @@ object SymDenotations {
// def withType(tp: Type): SymDenotation = ???
+ def asClass: ClassDenotation = asInstanceOf[ClassDenotation]
+
override protected def copy(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
+ /** The class implementing this module */
def moduleClass(implicit ctx: Context): Symbol =
if (this.isModuleVal) info.typeSymbol else NoSymbol
+ /** The module implemented by this module class */
+ def sourceModule(implicit ctx: Context): Symbol =
+ if (this.isModuleClass) this.asClass.selfType.termSymbol else NoSymbol
+
/** Desire to re-use the field in ClassSymbol which stores the source
* file to also store the classfile, but without changing the behavior
* of sourceFile (which is expected at least in the IDE only to
@@ -283,9 +290,9 @@ object SymDenotations {
def isNonValueClass(implicit ctx: Context): Boolean =
isClass && !isSubClass(defn.AnyValClass)
- def typeParams: List[TypeSymbol] = unsupported("typeParams")
+ def typeParams(implicit ctx: Context): List[TypeSymbol] = unsupported("typeParams")
- def thisType(implicit ctx: Context): Type = unsupported("thisType")
+ def thisType(implicit ctx: Context): Type = NoPrefix
def typeConstructor(implicit ctx: Context): TypeRef =
TypeRef(owner.thisType, name.asTypeName)
@@ -308,90 +315,14 @@ object SymDenotations {
owner: Symbol = this.owner,
name: Name = this.name,
initFlags: FlagSet = this.flags,
+ privateWithin: Symbol = this.privateWithin,
info: Type = this.info) =
- new CompleteSymDenotation(sym, owner, name, initFlags, info)
- }
-
- trait isComplete extends SymDenotation {
- privateWithin = NoSymbol
- annotations = Nil
- def tryLoad(): Unit = unsupported("tryLoad")
- def tryComplete(): Unit = unsupported("tryComplete")
- }
-
- abstract class Completer[Denot <: SymDenotation] {
- def handleCycle(denot: Denot): Unit
- def load(denot: Denot): Unit
- def complete(denot: Denot): Unit
- }
-
- type SymCompleter = Completer[LazySymDenotation]
- type ClassCompleter = Completer[LazyClassDenotation]
-
- class ModuleCompleter(moduleClass: ClassSymbol) extends Completer[LazySymDenotation] {
- def handleCycle(denot: LazySymDenotation): Unit = ???
- def load(denot: LazySymDenotation): Unit = ???
- def complete(denot: LazySymDenotation): Unit = ???
- }
-
- trait isLazy[Denot <: SymDenotation] extends SymDenotation { this: Denot =>
-
- protected def completer: Completer[Denot]
-
- protected def tryLoad(): Unit = try {
- if (flags is Locked) throw new CyclicReference(symbol)
- setFlags(Locked)
- completer.load(this)
- } catch {
- case ex: CyclicReference => completer.handleCycle(this)
- } finally {
- flags &~= Locked
- }
-
- protected def tryComplete(): Unit = try {
- if (flags is Locked) throw new CyclicReference(symbol)
- completer.complete(this)
- } catch {
- case ex: CyclicReference => completer.handleCycle(this)
- } finally {
- flags &~= Locked
- }
+ new CompleteSymDenotation(sym, owner, name, initFlags, privateWithin, info)
}
- class CompleteSymDenotation(
- val symbol: Symbol,
- val owner: Symbol,
- val name: Name,
- initFlags: FlagSet,
- val info: Type
- ) extends SymDenotation(initFlags) with isComplete
-
- class LazyModuleDenotation(
- symbol: Symbol,
- owner: Symbol,
- name: Name,
- initFlags: FlagSet,
- val moduleClass: ClassSymbol
- ) extends LazySymDenotation(symbol, owner, name, initFlags, new ModuleCompleter(moduleClass)) {
-
- override val info: Type = ???
- }
-
-
- class LazySymDenotation(
- val symbol: Symbol,
- val owner: Symbol,
- val name: Name,
- initFlags: FlagSet,
- val completer: SymCompleter
- ) extends SymDenotation(initFlags) with isLazy[LazySymDenotation] {
-
- private[this] var _info: Type = _
-
- override def info = { ensureCompleted(); _info }
- }
-
- abstract class ClassDenotation(initFlags: FlagSet, assocFile: AbstractFile)(implicit ctx: Context)
+ // Note: important to leave initctx non-implicit, and to check that it is not
+ // retained after object construction.
+ abstract class ClassDenotation(initFlags: FlagSet, assocFile: AbstractFile)(initctx: Context)
extends SymDenotation(initFlags) {
import NameFilter._
import util.LRU8Cache
@@ -404,18 +335,18 @@ object SymDenotations {
def decls: Scope
- val info = ClassInfo(owner.thisType, this)
+ val info = ClassInfo(owner.thisType(initctx), this)(initctx)
override def associatedFile(implicit ctx: Context): AbstractFile = assocFile
private[this] var _typeParams: List[TypeSymbol] = _
- override final def typeParams: List[TypeSymbol] = {
+ override final def typeParams(implicit ctx: Context): List[TypeSymbol] = {
val tparams = _typeParams
if (tparams != null) tparams else computeTypeParams
}
- private def computeTypeParams: List[TypeSymbol] =
+ private def computeTypeParams(implicit ctx: Context): List[TypeSymbol] =
(preCompleteDecls.toList filter (_ is TypeParam)).asInstanceOf[List[TypeSymbol]]
protected def preCompleteDecls: Scope
@@ -435,7 +366,7 @@ object SymDenotations {
}
// todo: apply same scheme to static objects/all objects?
- private def computeThisType: Type =
+ private def computeThisType(implicit ctx: Context): Type =
if (isPackageClass && !isRoot)
TermRef(owner.thisType, name.toTermName)
else
@@ -664,11 +595,36 @@ object SymDenotations {
owner: Symbol = this.owner,
name: Name = this.name,
initFlags: FlagSet = this.flags,
+ privateWithin: Symbol = this.privateWithin,
parents: List[TypeRef] = this.parents,
selfType: Type = this.selfType,
decls: Scope = this.decls,
- assocFile: AbstractFile = this.assocFile) =
- new CompleteClassDenotation(sym, owner, name, initFlags, parents, selfType, decls, assocFile)
+ assocFile: AbstractFile = this.assocFile)(implicit ctx: Context) =
+ new CompleteClassDenotation(sym, owner, name, initFlags, privateWithin, parents, selfType, decls, assocFile)(ctx)
+ }
+
+// -------- Concrete classes for instantiating denotations --------------------------
+
+ class CompleteSymDenotation(
+ val symbol: Symbol,
+ val owner: Symbol,
+ val name: Name,
+ initFlags: FlagSet,
+ val privateWithin: Symbol,
+ val info: Type
+ ) extends SymDenotation(initFlags)
+
+ class LazySymDenotation(
+ val symbol: Symbol,
+ val owner: Symbol,
+ val name: Name,
+ initFlags: FlagSet,
+ var completer: SymCompleter
+ ) extends SymDenotation(initFlags) with isLazy[LazySymDenotation] {
+
+ private[this] var _info: Type = _
+ protected[core] def info_=(tp: Type) = if (_info == null) _info = tp
+ override def info = { if (info == null) tryComplete(); _info }
}
class CompleteClassDenotation(
@@ -676,12 +632,13 @@ object SymDenotations {
val owner: Symbol,
val name: Name,
initFlags: FlagSet,
+ val privateWithin: Symbol,
val parents: List[TypeRef],
optSelfType: Type,
val decls: Scope,
assocFile: AbstractFile = null
- )(implicit ctx: Context) extends ClassDenotation(initFlags, assocFile) with isComplete {
- val selfType = if (optSelfType == NoType) thisType else optSelfType
+ )(initctx: Context) extends ClassDenotation(initFlags, assocFile)(initctx) {
+ val selfType = if (optSelfType == NoType) thisType(initctx) else optSelfType
final def preCompleteDecls = decls
}
@@ -690,27 +647,95 @@ object SymDenotations {
val owner: Symbol,
val name: Name,
initFlags: FlagSet,
- val completer: ClassCompleter,
+ var completer: ClassCompleter,
assocFile: AbstractFile = null
- )(implicit ctx: Context) extends ClassDenotation(initFlags, assocFile) with isLazy[LazyClassDenotation] {
+ )(initctx: Context) extends ClassDenotation(initFlags, assocFile)(initctx) with isLazy[LazyClassDenotation] {
+
+ private[this] var _parents: List[TypeRef] = null
+ private[this] var _selfType: Type = null
+ private[this] var _decls: Scope = null
- protected var _parents: List[TypeRef] = null
- protected var _selfType: Type = null
- protected var _decls: Scope = null
+ protected[core] def parents_=(ps: List[TypeRef]) = if (_parents == null) _parents = ps
+ protected[core] def selfType_=(tp: Type) = if (_selfType == null) _selfType = tp
+ protected[core] def decls_=(sc: Scope) = if (_decls == null) _decls = sc
- final def parents: List[TypeRef] = { ensureCompleted(); _parents }
- final def selfType: Type = { ensureCompleted(); _selfType }
- final def decls: Scope = { ensureCompleted(); _decls }
- final def preCompleteDecls = {ensureLoaded(); _decls }
+ final def parents: List[TypeRef] = { if (_parents == null) tryComplete(); _parents }
+ def selfType: Type = { if (_selfType == null) tryComplete(); _selfType }
+ final def decls: Scope = { if (_decls == null) tryComplete(); _decls }
+ final def preCompleteDecls = { if (_decls == null) tryLoad(); _decls }
}
- object NoDenotation extends SymDenotation(EmptyFlags) with isComplete {
+ object NoDenotation extends SymDenotation(EmptyFlags) {
override def symbol: Symbol = NoSymbol
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
override def name: Name = "<none>".toTermName
override def info: Type = NoType
+ override def privateWithin = NoSymbol
}
+// ---- Completion --------------------------------------------------------
+
+ trait isLazy[Denot <: SymDenotation] extends SymDenotation { this: Denot =>
+
+ protected def completer: Completer[Denot]
+ protected def completer_= (c: Completer[Denot])
+
+ override def isLoaded = _privateWithin != null
+ override def isCompleted = completer == null
+
+ override protected[core] def tryLoad(): Unit =
+ try {
+ if (flags is Locked) throw new CyclicReference(symbol)
+ setFlags(Locked)
+ completer.load(this)
+ } finally {
+ flags &~= Locked
+ }
+
+ override protected[core] def tryComplete(): Unit = {
+ val c = completer
+ completer = null
+ if (c == null) throw new CyclicReference(symbol)
+ c.complete(this)
+ }
+
+ private[this] var _privateWithin: Symbol = _
+ def privateWithin: Symbol = { if (_privateWithin == null) tryLoad(); _privateWithin }
+ protected[core] def privateWithin_=(sym: Symbol): Unit = { _privateWithin = sym }
+ }
+
+ abstract class Completer[Denot <: SymDenotation] extends DotClass {
+ /** Load symbol, setting flags and privateWithin, and typeParams for classes
+ * By default same as complete but can be overridden
+ */
+ def load(denot: Denot): Unit = complete(denot)
+
+ /** Complete symbol, setting all its properties */
+ def complete(denot: Denot): Unit
+ }
+
+ type SymCompleter = Completer[LazySymDenotation]
+ type ClassCompleter = Completer[LazyClassDenotation]
+
+ class ModuleCompleter(implicit ctx: Context) extends Completer[LazySymDenotation] {
+ def classDenot(denot: LazySymDenotation) =
+ denot.moduleClass.denot.asInstanceOf[LazyClassDenotation]
+ def copyLoadedFields(denot: LazySymDenotation, from: LazyClassDenotation) = {
+ denot.setFlags(from.flags.toTermFlags & ModuleFlags)
+ denot.privateWithin = from.privateWithin
+ }
+ def copyCompletedFields(denot: LazySymDenotation, from: LazyClassDenotation) = {
+ copyLoadedFields(denot, from)
+ denot.annotations = from.annotations filter (_.appliesToModule)
+ }
+ override def load(denot: LazySymDenotation): Unit =
+ copyLoadedFields(denot, classDenot(denot))
+ def complete(denot: LazySymDenotation): Unit =
+ copyCompletedFields(denot, classDenot(denot))
+ }
+
+// ---- Name filter --------------------------------------------------------
+
object NameFilter {
final val WordSizeLog = 6
final val DefinedNamesWords = 16
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index f947a23d8..972242fbd 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -31,6 +31,14 @@ abstract class SymbolLoaders(implicit ctx: Context) {
enterIfNew(owner, cls, completer)
}
+ /** Enter module with given `name` into scope of `root`
+ * and give them `completer` as type.
+ */
+ def enterModule(owner: Symbol, name: String, completer: SymbolLoader): Symbol = {
+ val module = ctx.newLazyModuleSymbol(owner, name.toTermName, EmptyFlags, completer)
+ enterIfNew(owner, module, completer)
+ }
+
abstract class SymbolLoader extends ClassCompleter
}
/*
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index 468e36cfd..a70e81d68 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -24,36 +24,79 @@ trait Symbols { this: Context =>
def newLazyTypeSymbol(owner: Symbol, name: TypeName, initFlags: FlagSet, completer: SymCompleter) =
new TypeSymbol(new LazySymDenotation(_, owner, name, initFlags, completer))
- def newLazyClassSymbol(owner: Symbol, name: TypeName, initFlags: FlagSet, completer: ClassCompleter, assocfile: AbstractFile = null) =
- new ClassSymbol(new LazyClassDenotation(_, owner, name, initFlags, completer, assocfile))
+ def newLazyClassSymbol(owner: Symbol, name: TypeName, initFlags: FlagSet, completer: ClassCompleter, assocFile: AbstractFile = null) =
+ new ClassSymbol(new LazyClassDenotation(_, owner, name, initFlags, completer, assocFile)(this))
- def newCompleteTermSymbol(
- owner: Symbol,
+ def newLazyModuleSymbol(owner: Symbol,
name: TermName,
flags: FlagSet,
- info: Type) =
- new TermSymbol(new CompleteSymDenotation(_, owner, name, flags, info))
+ completer: ClassCompleter,
+ assocFile: AbstractFile = null)
+ = {
+ val module = newLazyTermSymbol(
+ owner, name, flags | Module, new ModuleCompleter)
+ val modcls = newLazyClassSymbol(
+ owner, name.toTypeName, flags | Module | Final, completer, assocFile)
+ module.denot.asInstanceOf[LazySymDenotation].info =
+ TypeRef(owner.thisType, modcls)
+ modcls.denot.asInstanceOf[LazyClassDenotation].selfType =
+ TermRef(owner.thisType, module)
+ module
+ }
- def newCompleteTypeSymbol(
+ def newTermSymbol(
+ owner: Symbol,
+ name: TermName,
+ flags: FlagSet,
+ info: Type,
+ privateWithin: Symbol = NoSymbol)
+ =
+ new TermSymbol(new CompleteSymDenotation(_, owner, name, flags, privateWithin, info))
+
+ def newTypeSymbol(
+ owner: Symbol,
+ name: TypeName,
+ flags: FlagSet,
+ info: Type,
+ privateWithin: Symbol = NoSymbol)
+ =
+ new TypeSymbol(new CompleteSymDenotation(_, owner, name, flags, privateWithin, info))
+
+ def newAliasTypeSymbol(owner: Symbol, name: TypeName, alias: Type, flags: FlagSet = EmptyFlags, privateWithin: Symbol = NoSymbol) =
+ newTypeSymbol(owner, name, flags, TypeBounds(alias, alias), privateWithin)
+
+ def newClassSymbol(
owner: Symbol,
name: TypeName,
flags: FlagSet,
- info: Type) =
- new TypeSymbol(new CompleteSymDenotation(_, owner, name, flags, info))
-
- def newAliasTypeSymbol(owner: Symbol, name: TypeName, alias: Type, flags: FlagSet = EmptyFlags) =
- newCompleteTypeSymbol(owner, name, flags, TypeBounds(alias, alias))
+ parents: List[TypeRef],
+ privateWithin: Symbol = NoSymbol,
+ optSelfType: Type = NoType,
+ decls: Scope = newScope,
+ assocFile: AbstractFile = null)
+ =
+ new ClassSymbol(new CompleteClassDenotation(
+ _, owner, name, flags, privateWithin, parents, optSelfType, decls, assocFile)(this))
- def newCompleteClassSymbol(
+ def newModuleSymbol(
owner: Symbol,
- name: TypeName,
+ name: TermName,
flags: FlagSet,
+ classFlags: FlagSet,
parents: List[TypeRef],
- optSelfType: Type = NoType,
+ privateWithin: Symbol = NoSymbol,
decls: Scope = newScope,
- assocFile: AbstractFile = null) =
- new ClassSymbol(new CompleteClassDenotation(
- _, owner, name, flags, parents, optSelfType, decls, assocFile))
+ assocFile: AbstractFile = null)(implicit ctx: Context)
+ = {
+ val module = newLazyTermSymbol(owner, name, flags, new ModuleCompleter)
+ val modcls = newClassSymbol(
+ owner, name.toTypeName, classFlags, parents, privateWithin,
+ optSelfType = TermRef(owner.thisType, module),
+ decls, assocFile)
+ module.denot.asInstanceOf[LazySymDenotation].info =
+ TypeRef(owner.thisType, modcls)
+ module
+ }
}
object Symbols {
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 459f219ac..256ab7721 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -623,8 +623,8 @@ object Types {
}
}
- final class TermRefBySym(prefix: Type, val fixedSym: TermSymbol)(implicit ctx: Context)
- extends TermRef(prefix, fixedSym.name) with HasFixedSym {
+ final class TermRefBySym(prefix: Type, val fixedSym: TermSymbol)(initctx: Context)
+ extends TermRef(prefix, fixedSym.name(initctx)) with HasFixedSym {
}
final class TermRefWithSignature(prefix: Type, name: TermName, override val signature: Signature) extends TermRef(prefix, name) {
@@ -633,8 +633,8 @@ object Types {
super.loadDenot.atSignature(signature)
}
- final class TypeRefBySym(prefix: Type, val fixedSym: TypeSymbol)(implicit ctx: Context)
- extends TypeRef(prefix, fixedSym.name) with HasFixedSym {
+ final class TypeRefBySym(prefix: Type, val fixedSym: TypeSymbol)(initctx: Context)
+ extends TypeRef(prefix, fixedSym.name(initctx)) with HasFixedSym {
}
final class CachedTermRef(prefix: Type, name: TermName) extends TermRef(prefix, name)
@@ -650,7 +650,7 @@ object Types {
def apply(prefix: Type, name: TermName)(implicit ctx: Context) =
unique(new CachedTermRef(prefix, name))
def apply(prefix: Type, sym: TermSymbol)(implicit ctx: Context) =
- unique(new TermRefBySym(prefix, sym))
+ unique(new TermRefBySym(prefix, sym)(ctx))
def apply(prefix: Type, name: TermName, signature: Signature)(implicit ctx: Context) =
unique(new TermRefWithSignature(prefix, name, signature))
}
@@ -659,7 +659,7 @@ object Types {
def apply(prefix: Type, name: TypeName)(implicit ctx: Context) =
unique(new CachedTypeRef(prefix, name))
def apply(prefix: Type, sym: TypeSymbol)(implicit ctx: Context) =
- unique(new TypeRefBySym(prefix, sym))
+ unique(new TypeRefBySym(prefix, sym)(ctx))
}
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
diff --git a/src/dotty/tools/io/Jar.scala b/src/dotty/tools/io/Jar.scala
index 449602409..6977f868d 100644
--- a/src/dotty/tools/io/Jar.scala
+++ b/src/dotty/tools/io/Jar.scala
@@ -11,8 +11,6 @@ import java.io.{ InputStream, OutputStream, IOException, FileNotFoundException,
import java.util.jar._
import scala.collection.JavaConverters._
import Attributes.Name
-import dotty.tools.io.ClassPath
-import reflect.io._
import scala.language.implicitConversions
// Attributes.Name instances: