aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-09 15:19:49 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-09 15:19:49 +0200
commit7a6bb3ccba3217bc15e3a1c038a1cce4dbd942e3 (patch)
tree5ca8c806a1414010a2aa8c62c319528386ea653c /src/dotty/tools
parent442c361aee87266fe6428f1d9a5da7de934c8cef (diff)
downloaddotty-7a6bb3ccba3217bc15e3a1c038a1cce4dbd942e3.tar.gz
dotty-7a6bb3ccba3217bc15e3a1c038a1cce4dbd942e3.tar.bz2
dotty-7a6bb3ccba3217bc15e3a1c038a1cce4dbd942e3.zip
Renamed creation methods of NamedTypes
Methods taking a fixed symbol are now called …withSym, methods taking a signature … withSig. The reason for the change is that we want to liberate the original method names to take optional denotations, thus avoiding to have to go through withDenot each time.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Annotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala2
-rw-r--r--src/dotty/tools/dotc/core/Substituters.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala2
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala4
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypedTrees.scala6
-rw-r--r--src/dotty/tools/dotc/core/Types.scala20
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala11
10 files changed, 25 insertions, 28 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala
index 3226e69ea..371df9e50 100644
--- a/src/dotty/tools/dotc/core/Annotations.scala
+++ b/src/dotty/tools/dotc/core/Annotations.scala
@@ -54,7 +54,7 @@ object Annotations {
deferred(atp.typeSymbol, New(atp, args))
def makeAlias(sym: TermSymbol)(implicit ctx: Context) =
- apply(defn.AliasAnnot, List(Ident(TermRef(sym.owner.thisType, sym.name, sym.signature).withDenot(sym))))
+ apply(defn.AliasAnnot, List(Ident(TermRef.withSig(sym.owner.thisType, sym.name, sym.signature).withDenot(sym))))
def makeChild(sym: Symbol)(implicit ctx: Context) =
apply(defn.ChildAnnot.typeConstructor.appliedTo(NamedType(sym.owner.thisType, sym.name).withDenot(sym)), Nil)
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 81e01a1e1..fba99439e 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -52,7 +52,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(NoPrefix, RootClass))
+ NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef.withSym(NoPrefix, RootClass))
lazy val EmptyPackageClass = ctx.newCompletePackageSymbol(RootClass, nme.EMPTY_PACKAGE).moduleClass.asClass
lazy val EmptyPackageVal = EmptyPackageClass.sourceModule
diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala
index 5d0dd6add..c0f0ad5db 100644
--- a/src/dotty/tools/dotc/core/Substituters.scala
+++ b/src/dotty/tools/dotc/core/Substituters.scala
@@ -88,7 +88,7 @@ trait Substituters { this: Context =>
var fs = from
var ts = to
while (fs.nonEmpty) {
- if (fs.head eq sym) return NamedType(tp.prefix, ts.head)
+ if (fs.head eq sym) return NamedType.withSym(tp.prefix, ts.head)
fs = fs.tail
ts = ts.tail
}
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index c5feb55cb..0b8f494d0 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -575,7 +575,7 @@ object SymDenotations {
* @throws ClassCastException is this is not a type
*/
final def symbolicRef(implicit ctx: Context): TypeRef =
- TypeRef(owner.thisType, symbol.asType)
+ TypeRef.withSym(owner.thisType, symbol.asType)
/** The variance of this type parameter as an Int, with
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index 11d1d6a1f..e2c5f9774 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -148,7 +148,7 @@ class SymbolLoaders {
def doComplete(root: SymDenotation) {
assert(root is PackageClass, root)
val pre = root.owner.thisType
- root.info = ClassInfo(pre, root.symbol.asClass, Nil, root.decls, TermRef(pre, sourceModule))
+ root.info = ClassInfo(pre, root.symbol.asClass, Nil, root.decls, TermRef.withSym(pre, 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 d040fc998..dced9823d 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -123,7 +123,7 @@ trait Symbols { this: Context =>
infoFn(module, modcls), privateWithin)
val mdenot = SymDenotation(
module, owner, name, modFlags | ModuleCreationFlags,
- if (cdenot.isCompleted) TypeRef(owner.thisType, name.toTypeName, modcls)
+ if (cdenot.isCompleted) TypeRef.withSym(owner.thisType, modcls)
else new ModuleCompleter(modcls)(condensed))
module.denot = mdenot
modcls.denot = cdenot
@@ -148,7 +148,7 @@ trait Symbols { this: Context =>
newModuleSymbol(
owner, name, modFlags, clsFlags,
(module, modcls) => ClassInfo(
- owner.thisType, modcls, parents, decls, TermRef(owner.thisType, module)),
+ owner.thisType, modcls, parents, decls, TermRef.withSym(owner.thisType, module)),
privateWithin, coord, assocFile)
/** Create a package symbol with associated package class
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index efededd7a..45bd6a9f9 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(NoPrefix, newSkolem(underlying))
+ def newSkolemSingleton(underlying: Type) = TermRef.withSym(NoPrefix, newSkolem(underlying))
final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = {
diff --git a/src/dotty/tools/dotc/core/TypedTrees.scala b/src/dotty/tools/dotc/core/TypedTrees.scala
index 32ccaeeac..ae4c82c3d 100644
--- a/src/dotty/tools/dotc/core/TypedTrees.scala
+++ b/src/dotty/tools/dotc/core/TypedTrees.scala
@@ -288,7 +288,7 @@ object TypedTrees {
def SharedTree(tree: Tree): SharedTree =
Trees.SharedTree(tree).withType(tree.tpe)
- def refType(sym: Symbol)(implicit ctx: Context) = NamedType(sym.owner.thisType, sym)
+ def refType(sym: Symbol)(implicit ctx: Context) = NamedType.withSym(sym.owner.thisType, sym)
// ------ Creating typed equivalents of trees that exist only in untyped form -------
@@ -305,7 +305,7 @@ object TypedTrees {
Apply(
Select(
New(tp),
- TermRef(tp.normalizedPrefix, tp.typeSymbol.primaryConstructor.asTerm)),
+ TermRef.withSym(tp.normalizedPrefix, tp.typeSymbol.primaryConstructor.asTerm)),
args)
/** An object def
@@ -363,7 +363,7 @@ object TypedTrees {
}
Block(
DefDef(meth, body) :: Nil,
- Typed(Ident(TermRef(NoPrefix, meth)), TypeTree(funtpe)))
+ Typed(Ident(TermRef.withSym(NoPrefix, meth)), TypeTree(funtpe)))
}
private class FindLocalDummyAccumulator(cls: ClassSymbol)(implicit ctx: Context) extends TreeAccumulator[Symbol] {
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index bcc2da498..22ea23b52 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1012,7 +1012,7 @@ object Types {
override def loadDenot(implicit ctx: Context): Denotation =
super.loadDenot.atSignature(sig)
override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRefWithSignature =
- TermRef(prefix, name, sig)
+ TermRef.withSig(prefix, name, sig)
override def equals(that: Any) = that match {
case that: TermRefWithSignature =>
this.prefix == that.prefix &&
@@ -1034,27 +1034,25 @@ object Types {
def apply(prefix: Type, name: Name)(implicit ctx: Context) =
if (name.isTermName) TermRef(prefix, name.asTermName)
else TypeRef(prefix, name.asTypeName)
- def apply(prefix: Type, sym: Symbol)(implicit ctx: Context) =
- if (sym.isTerm) TermRef(prefix, sym.asTerm)
- else TypeRef(prefix, sym.asType)
+ def withSym(prefix: Type, sym: Symbol)(implicit ctx: Context) =
+ if (sym.isTerm) TermRef.withSym(prefix, sym.asTerm)
+ else TypeRef.withSym(prefix, sym.asType)
}
object TermRef {
def apply(prefix: Type, name: TermName)(implicit ctx: Context): TermRef =
unique(new CachedTermRef(prefix, name))
- def apply(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRefBySym =
+ def withSym(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRefBySym =
unique(new TermRefBySym(prefix, sym.name, sym))
- def apply(prefix: Type, name: TermName, sig: Signature)(implicit ctx: Context): TermRefWithSignature =
+ def withSig(prefix: Type, name: TermName, sig: Signature)(implicit ctx: Context): TermRefWithSignature =
unique(new TermRefWithSignature(prefix, name, sig))
}
object TypeRef {
def apply(prefix: Type, name: TypeName)(implicit ctx: Context): TypeRef =
unique(new CachedTypeRef(prefix, name))
- def apply(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRefBySym =
- apply(prefix, sym.name, sym)
- def apply(prefix: Type, name: TypeName, sym: TypeSymbol)(implicit ctx: Context): TypeRefBySym =
- unique(new TypeRefBySym(prefix, name, sym))
+ def withSym(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRefBySym =
+ unique(new TypeRefBySym(prefix, sym.name, sym))
}
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
@@ -1427,7 +1425,7 @@ object Types {
else tp.substThis(cls, prefix)
def typeConstructor(implicit ctx: Context): Type =
- if ((cls is PackageClass) || cls.owner.isTerm) TypeRef(prefix, cls)
+ if ((cls is PackageClass) || cls.owner.isTerm) TypeRef.withSym(prefix, cls)
else TypeRef(prefix, cls.name).withDenot(cls.denot.asSeenFrom(prefix))
// cached because baseType needs parents
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 1e272e894..4a5c543a4 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -112,7 +112,7 @@ object UnPickler {
}
val ost =
if ((optSelfType eq NoType) && (denot is ModuleClass))
- TermRef(denot.owner.thisType, denot.sourceModule.asTerm)
+ TermRef.withSym(denot.owner.thisType, denot.sourceModule.asTerm)
else optSelfType
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
}
@@ -603,8 +603,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
case SINGLEtpe =>
val pre = readTypeRef()
val sym = readDisambiguatedSymbolRef(_.isParameterless)
- if (isLocal(sym)) TermRef(pre, sym.asTerm)
- else TermRef(pre, sym.name.asTermName, NotAMethod).withDenot(sym)
+ if (isLocal(sym)) TermRef.withSym(pre, sym.asTerm)
+ else TermRef.withSig(pre, sym.name.asTermName, NotAMethod).withDenot(sym)
case SUPERtpe =>
val thistpe = readTypeRef()
val supertpe = readTypeRef()
@@ -633,9 +633,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
}
val tycon =
if (isLocal(sym)) {
- TypeRef(
- if ((pre eq NoPrefix) && (sym is TypeParam)) sym.owner.thisType
- else pre,
+ TypeRef.withSym(
+ if ((pre eq NoPrefix) && (sym is TypeParam)) sym.owner.thisType else pre,
sym.asType)
} else TypeRef(pre, sym.name.asTypeName).withDenot(sym)
val args = until(end, readTypeRef)