aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-11-25 13:11:29 +0100
committerMartin Odersky <odersky@gmail.com>2013-11-25 13:16:19 +0100
commit510ae8bf1c6932595c1313c4b7a8027c435640be (patch)
tree562a816379be6cd8997c079ffabcfe1eaf7c39f6
parent19d92a561b06dc257a71ba0f330fe4e594d1fd06 (diff)
downloaddotty-510ae8bf1c6932595c1313c4b7a8027c435640be.tar.gz
dotty-510ae8bf1c6932595c1313c4b7a8027c435640be.tar.bz2
dotty-510ae8bf1c6932595c1313c4b7a8027c435640be.zip
Cleanup of TermRef.withSym and TypeRef.withSym
All occurrences replaced by select, or second version of Term/TypeRef.apply
-rw-r--r--src/dotty/tools/dotc/ast/TypedTrees.scala4
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala2
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala6
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala2
-rw-r--r--src/dotty/tools/dotc/core/Types.scala16
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala12
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala6
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala4
11 files changed, 27 insertions, 31 deletions
diff --git a/src/dotty/tools/dotc/ast/TypedTrees.scala b/src/dotty/tools/dotc/ast/TypedTrees.scala
index 3dd5b3128..bf3b3633b 100644
--- a/src/dotty/tools/dotc/ast/TypedTrees.scala
+++ b/src/dotty/tools/dotc/ast/TypedTrees.scala
@@ -128,7 +128,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val targetTpt = if (targetType.exists) TypeTree(targetType) else EmptyTree
Block(
DefDef(meth, rhsFn) :: Nil,
- Closure(Nil, Ident(TermRef.withSym(NoPrefix, meth)), targetTpt))
+ Closure(Nil, Ident(TermRef(NoPrefix, meth)), targetTpt))
}
def Match(selector: Tree, cases: List[CaseDef])(implicit ctx: Context): Match =
@@ -311,7 +311,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
Apply(
Select(
New(tp withoutArgs targs),
- TermRef.withSym(tp.normalizedPrefix, tp.typeSymbol.primaryConstructor.asTerm))
+ TermRef(tp.normalizedPrefix, tp.typeSymbol.primaryConstructor.asTerm))
.appliedToTypes(targs),
args)
}
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 81ae3250e..f8ec3c57b 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -84,7 +84,7 @@ class Definitions(implicit ctx: Context) {
lazy val RootClass: ClassSymbol = ctx.newPackageSymbol(
NoSymbol, nme.ROOT, (root, rootcls) => ctx.rootLoader(root)).moduleClass.asClass
lazy val RootPackage: TermSymbol = ctx.newSymbol(
- NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef.withSym(NoPrefix, RootClass))
+ NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef(NoPrefix, RootClass))
lazy val EmptyPackageClass = ctx.newCompletePackageSymbol(RootClass, nme.EMPTY_PACKAGE).moduleClass.asClass
lazy val EmptyPackageVal = EmptyPackageClass.sourceModule.entered
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index 8c128e808..a02af441f 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -152,7 +152,7 @@ class SymbolLoaders {
assert(root is PackageClass, root)
def maybeModuleClass(classRep: ClassPath#ClassRep) = classRep.name.last == '$'
val pre = root.owner.thisType
- root.info = ClassInfo(pre, root.symbol.asClass, Nil, preDecls, TermRef.withSym(pre, sourceModule))
+ root.info = ClassInfo(pre, root.symbol.asClass, Nil, preDecls, pre select sourceModule)
if (!sourceModule.isCompleted)
sourceModule.completer.complete(sourceModule)
if (!root.isRoot) {
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index e18286426..d6985039c 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -125,7 +125,7 @@ trait Symbols { this: Context =>
infoFn(module, modcls), privateWithin)
val mdenot = SymDenotation(
module, owner, name, modFlags | ModuleCreationFlags,
- if (cdenot.isCompleted) TypeRef.withSym(owner.thisType, modclsName, modcls)
+ if (cdenot.isCompleted) TypeRef(owner.thisType, modclsName) withSym modcls
else new ModuleCompleter(modcls)(condensed))
module.denot = mdenot
modcls.denot = cdenot
@@ -150,7 +150,7 @@ trait Symbols { this: Context =>
newModuleSymbol(
owner, name, modFlags, clsFlags,
(module, modcls) => ClassInfo(
- owner.thisType, modcls, parents, decls, TermRef.withSym(owner.thisType, name, module)),
+ owner.thisType, modcls, parents, decls, TermRef(owner.thisType, name) withSym module),
privateWithin, coord, assocFile)
/** Create a package symbol with associated package class
@@ -231,7 +231,7 @@ trait Symbols { this: Context =>
for (name <- names) {
val tparam = newNakedSymbol[TypeName](NoCoord)
tparamBuf += tparam
- trefBuf += TypeRef.withSym(owner.thisType, name, tparam)
+ trefBuf += TypeRef(owner.thisType, name) withSym tparam
}
val tparams = tparamBuf.toList
val bounds = boundsFn(trefBuf.toList)
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index c7b75e0b8..292d48269 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -4,7 +4,7 @@ import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._
trait TypeOps { this: Context =>
- def newSkolemSingleton(underlying: Type) = TermRef.withSym(NoPrefix, newSkolem(underlying))
+ def newSkolemSingleton(underlying: Type) = TermRef(NoPrefix, newSkolem(underlying))
final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = {
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index c1a7bced5..965c194fb 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -619,10 +619,10 @@ object Types {
/** The type <this . name> with given symbol, reduced if possible */
def select(sym: Symbol)(implicit ctx: Context): Type =
- if (sym.isTerm) TermRef.withSym(this, sym.asTerm)
+ if (sym.isTerm) TermRef(this, sym.asTerm)
else {
val res = lookupRefined(this, sym.name)
- if (res.exists) res else TypeRef.withSym(this, sym.asType)
+ if (res.exists) res else TypeRef(this, sym.asType)
}
protected def lookupRefined(pre: Type, name: Name)(implicit ctx: Context): Type = pre.stripTypeVar match {
@@ -1199,10 +1199,8 @@ object Types {
object TermRef {
def apply(prefix: Type, name: TermName)(implicit ctx: Context): TermRef =
unique(new CachedTermRef(prefix, name))
- def withSym(prefix: Type, name: TermName, sym: TermSymbol)(implicit ctx: Context): TermRef =
- apply(prefix, name) withSym sym
- def withSym(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
- withSym(prefix, sym.name, sym)
+ def apply(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
+ apply(prefix, sym.name) withSym sym
def withSig(prefix: Type, name: TermName, sig: Signature)(implicit ctx: Context): TermRef =
unique(new TermRefWithSignature(prefix, name, sig))
}
@@ -1210,10 +1208,8 @@ object Types {
object TypeRef {
def apply(prefix: Type, name: TypeName)(implicit ctx: Context): TypeRef =
unique(new CachedTypeRef(prefix, name))
- def withSym(prefix: Type, name: TypeName, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
- apply(prefix, name) withSym sym
- def withSym(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
- withSym(prefix, sym.name, sym)
+ def apply(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
+ apply(prefix, sym.name) withSym sym
}
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 415bc250a..57fc3007a 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -103,7 +103,7 @@ object UnPickler {
}
val ost =
if ((selfInfo eq NoType) && (denot is ModuleClass))
- TermRef.withSym(denot.owner.thisType, denot.sourceModule.asTerm)
+ denot.owner.thisType select denot.sourceModule
else selfInfo
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
}
@@ -598,7 +598,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
case SINGLEtpe =>
val pre = readTypeRef()
val sym = readDisambiguatedSymbolRef(_.info.isParameterless)
- if (isLocal(sym) || (pre == NoPrefix)) TermRef.withSym(pre, sym.asTerm)
+ if (isLocal(sym) || (pre == NoPrefix)) pre select sym
else TermRef.withSig(pre, sym.name.asTermName, NotAMethod) // !!! should become redundant
case SUPERtpe =>
val thistpe = readTypeRef()
@@ -628,10 +628,10 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
}
val tycon =
if (isLocal(sym) || pre == NoPrefix) {
- TypeRef.withSym(
- if ((pre eq NoPrefix) && (sym is TypeParam)) sym.owner.thisType else pre,
- sym.asType)
- } else TypeRef(pre, sym.name.asTypeName)
+ val pre1 = if ((pre eq NoPrefix) && (sym is TypeParam)) sym.owner.thisType else pre
+ pre1 select sym
+ }
+ else TypeRef(pre, sym.name.asTypeName)
val args = until(end, readTypeRef)
// if (args.nonEmpty) { // DEBUG
// println(s"reading app type $tycon $args")
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index ae9a70c34..901d44800 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -195,7 +195,7 @@ trait Applications extends Compatibility { self: Typer =>
def findDefaultGetter(n: Int)(implicit ctx: Context): Type = {
def getterName = methRef.name.toTermName.defaultGetterName(n)
def ref(pre: Type, sym: Symbol): Type =
- if (pre.exists && sym.isTerm) TermRef.withSym(pre, sym.asTerm) else NoType
+ if (pre.exists && sym.isTerm) pre select sym else NoType
val meth = methRef.symbol
if (meth.hasDefaultParams)
methRef.prefix match {
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index c39b409c8..dbe86d3c9 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -193,8 +193,8 @@ trait ImplicitRunInfo { self: RunInfo =>
comps ++= implicitScope(pre).companionRefs
def addClassScope(cls: ClassSymbol): Unit = {
def addRef(companion: TermRef): Unit = {
- val comp1 @ TermRef(p, _) = companion.asSeenFrom(pre, companion.symbol.owner)
- comps += TermRef.withSym(p, comp1.symbol.asTerm).withDenot(comp1.denot)
+ val comp1 @ TermRef(_, _) = companion.asSeenFrom(pre, companion.symbol.owner)
+ comps += comp1
}
def addParentScope(parent: TypeRef): Unit = {
implicitScope(parent).companionRefs foreach addRef
@@ -420,5 +420,5 @@ class TermRefSet(implicit ctx: Context) extends mutable.Traversable[TermRef] {
override def foreach[U](f: TermRef => U): Unit =
for (sym <- elems.keysIterator)
for (pre <- elems(sym))
- f(TermRef.withSym(pre, sym))
+ f(TermRef(pre, sym))
} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 4c3166bd9..09ce41167 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -338,7 +338,7 @@ class Namer { typer: Typer =>
case sig: TypeRef =>
sig
case sig: ClassInfo =>
- sig.derivedClassInfo(sig.prefix, sig.classParents, TermRef.withSym(sig.prefix, sourceModule.asTerm))
+ sig.derivedClassInfo(sig.prefix, sig.classParents, sig.prefix select sourceModule)
case _ =>
sig
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 74ad45390..a4b968c9a 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -574,7 +574,7 @@ class Typer extends Namer with Applications with Implicits {
else cx.tree match {
case ddef: DefDef =>
val meth = ddef.symbol
- val from = Ident(TermRef.withSym(NoPrefix, meth.asTerm))
+ val from = Ident(TermRef(NoPrefix, meth.asTerm))
val proto =
if (meth.isConstructor)
defn.UnitType
@@ -695,7 +695,7 @@ class Typer extends Namer with Applications with Implicits {
def typedBind(tree: untpd.Bind, pt: Type)(implicit ctx: Context): Bind = track("typedBind") {
val body1 = typed(tree.body, pt)
val sym = ctx.newSymbol(ctx.owner, tree.name.asTermName, EmptyFlags, pt, coord = tree.pos)
- cpy.Bind(tree, tree.name, body1) withType TermRef.withSym(NoPrefix, sym)
+ cpy.Bind(tree, tree.name, body1) withType TermRef(NoPrefix, sym)
}
def typedAlternative(tree: untpd.Alternative, pt: Type)(implicit ctx: Context): Alternative = track("typedAlternative") {