aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala2
-rw-r--r--src/dotty/tools/dotc/ast/TypedTrees.scala22
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala42
-rw-r--r--src/dotty/tools/dotc/core/Types.scala4
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala13
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--src/dotty/tools/dotc/typer/EtaExpansion.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala4
-rw-r--r--src/dotty/tools/dotc/typer/ImportInfo.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala14
13 files changed, 58 insertions, 57 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 62f02dc82..d489aec44 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -551,7 +551,7 @@ object desugar {
else if (arity == 1) ts.head
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleClass.typeRef), ts)
else if (arity == 0) unitLiteral
- else Apply(ref(tupleClass.companionModule.symRef), ts)
+ else Apply(ref(tupleClass.companionModule.valRef), ts)
}
case WhileDo(cond, body) =>
// { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() }
diff --git a/src/dotty/tools/dotc/ast/TypedTrees.scala b/src/dotty/tools/dotc/ast/TypedTrees.scala
index 315796c65..3dd5b3128 100644
--- a/src/dotty/tools/dotc/ast/TypedTrees.scala
+++ b/src/dotty/tools/dotc/ast/TypedTrees.scala
@@ -201,7 +201,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
untpd.TypeBoundsTree(lo, hi).withType(TypeBounds(lo.tpe, hi.tpe)).checked
def Bind(sym: TermSymbol, body: Tree)(implicit ctx: Context): Bind =
- untpd.Bind(sym.name, body).withType(sym.symRef).checked
+ untpd.Bind(sym.name, body).withType(sym.termRef).checked
def Alternative(trees: List[Tree])(implicit ctx: Context): Alternative =
untpd.Alternative(trees).withType(ctx.typeComparer.lub(trees map (_.tpe))).checked
@@ -215,7 +215,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
def ValDef(sym: TermSymbol, rhs: Tree = EmptyTree)(implicit ctx: Context): ValDef =
- untpd.ValDef(Modifiers(sym), sym.name, TypeTree(sym.info), rhs).withType(sym.symRef).checked
+ untpd.ValDef(Modifiers(sym), sym.name, TypeTree(sym.info), rhs).withType(sym.valRef).checked
def DefDef(sym: TermSymbol, rhs: Tree = EmptyTree)(implicit ctx: Context): DefDef =
DefDef(sym, Function.const(rhs) _)
@@ -234,21 +234,21 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def valueParam(name: TermName, info: Type): TermSymbol =
ctx.newSymbol(sym, name, TermParam, info)
val params = (paramNames, paramTypes).zipped.map(valueParam)
- val (paramss, rtp) = valueParamss(tp.instantiate(params map (_.symRef)))
+ val (paramss, rtp) = valueParamss(tp.instantiate(params map (_.termRef)))
(params :: paramss, rtp)
case tp => (Nil, tp)
}
val (vparamss, rtp) = valueParamss(mtp)
- val argss = vparamss map (_ map (vparam => Ident(vparam.symRef)))
+ val argss = vparamss map (_ map (vparam => Ident(vparam.termRef)))
untpd.DefDef(
Modifiers(sym), sym.name, tparams map TypeDef,
vparamss map (_ map (ValDef(_))), TypeTree(rtp), rhsFn(argss))
- .withType(sym.symRef).checked
+ .withType(sym.termRefWithSig).checked
}
def TypeDef(sym: TypeSymbol)(implicit ctx: Context): TypeDef =
untpd.TypeDef(Modifiers(sym), sym.name, TypeTree(sym.info))
- .withType(sym.symRef).checked
+ .withType(sym.typeRef).checked
def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree])(implicit ctx: Context): TypeDef = {
val parents = cls.info.parents map (TypeTree(_))
@@ -265,16 +265,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val localDummy = ((NoSymbol: Symbol) /: body)(findLocalDummy)
.orElse(ctx.newLocalDummy(cls))
val impl = untpd.Template(constr, parents, selfType, newTypeParams ++ body)
- .withType(localDummy.symRef).checked
+ .withType(localDummy.termRef).checked
untpd.TypeDef(Modifiers(cls), cls.name, impl)
- .withType(cls.symRef).checked
+ .withType(cls.typeRef).checked
}
def Import(expr: Tree, selectors: List[untpd.Tree])(implicit ctx: Context): Import =
- untpd.Import(expr, selectors).withType(ctx.newImportSymbol(SharedTree(expr)).symRef).checked
+ untpd.Import(expr, selectors).withType(ctx.newImportSymbol(SharedTree(expr)).termRef).checked
def PackageDef(pid: RefTree, stats: List[Tree])(implicit ctx: Context): PackageDef =
- untpd.PackageDef(pid, stats).withType(pid.symbol.symRef).checked
+ untpd.PackageDef(pid, stats).withType(pid.symbol.namedType).checked
def Annotated(annot: Tree, arg: Tree)(implicit ctx: Context): Annotated =
untpd.Annotated(annot, arg).withType(AnnotatedType(Annotation(annot), arg.tpe)).checked
@@ -417,7 +417,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val newOwner = ownerMap(sym.owner)
val newInfo = typeMap(sym.info)
if ((newOwner ne sym.owner) || (newInfo ne sym.info))
- bind.withType(sym.copy(owner = newOwner, info = newInfo).symRef)
+ bind.withType(sym.copy(owner = newOwner, info = newInfo).namedType)
else
bind
case tree1 =>
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index f7f3bde87..feb7e2b1b 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -42,7 +42,7 @@ class Definitions(implicit ctx: Context) {
val paramDecls = newScope
val typeParam = newSyntheticTypeParam(cls, paramDecls, paramFlags)
def instantiate(tpe: Type) =
- if (tpe.typeParams.nonEmpty) tpe.appliedTo(typeParam.symTypeRef)
+ if (tpe.typeParams.nonEmpty) tpe.appliedTo(typeParam.typeRef)
else tpe
val parents = parentConstrs.toList map instantiate
val parentRefs: List[TypeRef] = ctx.normalizeToRefs(parents, cls, paramDecls)
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 2e90f3170..9ab57802b 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -34,9 +34,7 @@ trait SymDenotations { this: Context =>
def stillValid(denot: SymDenotation): Boolean =
if (denot is ValidForever) true
- else if (denot.owner is PackageClass)
- (denot.owner.decls.lookup(denot.name) eq denot.symbol) ||
- (denot is ModuleClass) && stillValid(denot.sourceModule) // !!! DEBUG - we should check why module classes are not entered
+ else if (denot.owner is PackageClass) denot.owner.decls.lookup(denot.name) eq denot.symbol
else stillValid(denot.owner)
}
object SymDenotations {
@@ -631,27 +629,33 @@ object SymDenotations {
/** The type This(cls), where cls is this class, NoPrefix for all other symbols */
def thisType(implicit ctx: Context): Type = NoPrefix
- /** The named typeref representing the type constructor for this type.
- * @throws ClassCastException is this is not a type
- */
+ /** The TypeRef representing this type denotation at its original location. */
def typeRef(implicit ctx: Context): TypeRef =
- if ((this is PackageClass) || owner.isTerm) symTypeRef
- else TypeRef(owner.thisType, name.asTypeName).withDenot(this)
+ TypeRef(owner.thisType, name.asTypeName).withDenot(this)
+
+ /** The TermRef representing this term denotation at its original location. */
+ def termRef(implicit ctx: Context): TermRef =
+ TermRef(owner.thisType, name.asTermName).withDenot(this)
- /** The symbolic typeref representing the type constructor for this type.
- * @throws ClassCastException is this is not a type
+ /** The TermRef representing this term denotation at its original location
+ * and at signature `NotAMethod`.
*/
- final def symTypeRef(implicit ctx: Context): TypeRef =
- TypeRef.withSym(owner.thisType, symbol.asType)
+ def valRef(implicit ctx: Context): TermRef =
+ TermRef.withSig(owner.thisType, name.asTermName, NotAMethod).withDenot(this)
- /** The symbolic termref pointing to this termsymbol
- * @throws ClassCastException is this is not a term
+ /** The TermRef representing this term denotation at its original location
+ * at the denotation's signature.
+ * @note Unlike `valRef` and `termRef`, this will force the completion of the
+ * denotation via a call to `info`.
*/
- def symTermRef(implicit ctx: Context): TermRef =
- TermRef.withSym(owner.thisType, symbol.asTerm)
+ def termRefWithSig(implicit ctx: Context): TermRef =
+ TermRef.withSig(owner.thisType, name.asTermName, signature).withDenot(this)
- def symRef(implicit ctx: Context): NamedType =
- if (isType) symTypeRef else symTermRef
+ /** The NamedType representing this denotation at its original location.
+ * Same as either `typeRef` or `termRefWithSig` depending whether this denotes a type or not.
+ */
+ def namedType(implicit ctx: Context): NamedType =
+ if (isType) typeRef else termRefWithSig
/** The variance of this type parameter or type member as an Int, with
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
@@ -1139,7 +1143,7 @@ object SymDenotations {
// only apply to the module but not to the module class. The right solution
// is to have the module class completer set the annotations of both the
// class and the module.
- denot.info = moduleClass.symTypeRef
+ denot.info = moduleClass.typeRef
denot.privateWithin = from.privateWithin
}
}
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 5617fa6cc..3c0dbd0e9 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -373,7 +373,7 @@ object Types {
// member in Super instead of Sub.
// As an example of this in the wild, see
// loadClassWithPrivateInnerAndSubSelf in ShowClassTests
- tp.cls.symTypeRef.findMember(name, pre, excluded) orElse d
+ tp.cls.typeRef.findMember(name, pre, excluded) orElse d
case tp: TypeRef =>
tp.denot.findMember(name, pre, excluded)
case tp: TypeProxy =>
@@ -691,7 +691,7 @@ object Types {
case _ =>
parents match {
case p :: _ => p
- case _ => defn.AnyClass.symTypeRef
+ case _ => defn.AnyClass.typeRef
}
}
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index b68f9eb6f..dbd8088bf 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -190,7 +190,7 @@ class ClassfileParser(
*/
def normalizeConstructorInfo() = {
val mt @ MethodType(paramnames, paramtypes) = denot.info
- val rt = classRoot.typeRef appliedTo (classRoot.typeParams map (_.symRef))
+ val rt = classRoot.typeRef appliedTo (classRoot.typeParams map (_.typeRef))
denot.info = mt.derivedMethodType(paramnames, paramtypes, rt)
addConstructorTypeParams(denot)
}
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 02db4b0b0..415bc250a 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -934,7 +934,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
val ldef = DefDef(symbol.asTerm, rhs)
def isCaseLabel(sym: Symbol) = sym.name.startsWith(nme.CASEkw)
if (isCaseLabel(symbol)) ldef
- else Block(ldef :: Nil, Apply(Ident(symbol.symRef), Nil))
+ else Block(ldef :: Nil, Apply(Ident(symbol.termRef), Nil))
case IMPORTtree =>
setSym()
@@ -955,7 +955,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
val self = readValDefRef()
val body = until(end, readTreeRef)
untpd.Template(???, parents, self, body) // !!! TODO: pull out primary constructor
- .withType(symbol.symRef)
+ .withType(symbol.namedType)
case BLOCKtree =>
val expr = readTreeRef()
@@ -1016,7 +1016,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
case RETURNtree =>
setSym()
- Return(readTreeRef(), Ident(symbol.symRef))
+ Return(readTreeRef(), Ident(symbol.termRef))
case TREtree =>
val block = readTreeRef()
@@ -1072,11 +1072,10 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
setSym()
val qualifier = readTreeRef()
val selector = readNameRef()
- Select(qualifier, symbol.symRef)
-
+ Select(qualifier, symbol.namedType)
case IDENTtree =>
setSymName()
- Ident(symbol.symRef)
+ Ident(symbol.namedType)
case LITERALtree =>
Literal(readConstantRef())
@@ -1095,7 +1094,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
case SELECTFROMTYPEtree =>
val qualifier = readTreeRef()
val selector = readTypeNameRef()
- SelectFromTypeTree(qualifier, symbol.symRef)
+ SelectFromTypeTree(qualifier, symbol.namedType)
case COMPOUNDTYPEtree =>
readTemplateRef()
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index f1b603b4a..ae9a70c34 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -698,7 +698,7 @@ trait Applications extends Compatibility { self: Typer =>
case tp1: PolyType =>
def bounds(tparamRefs: List[TypeRef]) = tp1.paramBounds map (_.substParams(tp1, tparamRefs))
val tparams = ctx.newTypeParams(alt1.symbol.owner, tp1.paramNames, EmptyFlags, bounds)
- isAsSpecific(alt1, tp1.instantiate(tparams map (_.symRef)), alt2, tp2)
+ isAsSpecific(alt1, tp1.instantiate(tparams map (_.typeRef)), alt2, tp2)
case tp1: MethodType =>
isApplicableToTypes(alt2, tp1.paramTypes)(ctx)
case _ =>
diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 155574c81..6854b0bc7 100644
--- a/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -26,7 +26,7 @@ object EtaExpansion {
val name = ctx.freshName(prefix).toTermName
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, expr.tpe, coord = positionCoord(expr.pos))
defs += ValDef(sym, expr)
- Ident(sym.symRef)
+ Ident(sym.valRef)
}
def liftArgs(defs: mutable.ListBuffer[Tree], methType: Type, args: List[Tree])(implicit ctx: Context) = {
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 10e3dbbca..c39b409c8 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -176,7 +176,7 @@ trait ImplicitRunInfo { self: RunInfo =>
case tp: TypeRef if tp.symbol.isAbstractOrAliasType =>
val pre = tp.prefix
def joinClass(tp: Type, cls: ClassSymbol) =
- AndType(tp, cls.symTypeRef.asSeenFrom(pre, cls.owner))
+ AndType(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
val lead = if (tp.prefix eq NoPrefix) defn.AnyType else apply(tp.prefix)
(lead /: tp.classSymbols)(joinClass)
case _ =>
@@ -202,7 +202,7 @@ trait ImplicitRunInfo { self: RunInfo =>
comps ++= implicitScope(pre.member(param.name).info).companionRefs
}
val companion = cls.companionModule
- if (companion.exists) addRef(companion.symTermRef)
+ if (companion.exists) addRef(companion.valRef)
cls.classParents foreach addParentScope
}
tp.classSymbols foreach addClassScope
diff --git a/src/dotty/tools/dotc/typer/ImportInfo.scala b/src/dotty/tools/dotc/typer/ImportInfo.scala
index a87dec069..14e2980d5 100644
--- a/src/dotty/tools/dotc/typer/ImportInfo.scala
+++ b/src/dotty/tools/dotc/typer/ImportInfo.scala
@@ -12,7 +12,7 @@ import typer.ErrorReporting.InfoString
object ImportInfo {
/** The import info for a root import from given symbol `sym` */
def rootImport(sym: Symbol)(implicit ctx: Context) = {
- val expr = tpd.Ident(sym.symTermRef)
+ val expr = tpd.Ident(sym.valRef)
val selectors = untpd.Ident(nme.WILDCARD) :: Nil
val imp = tpd.Import(expr, selectors)
new ImportInfo(imp.symbol, selectors, rootImport = true)
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index c8cc7452c..4c3166bd9 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -337,8 +337,6 @@ class Namer { typer: Typer =>
sig match {
case sig: TypeRef =>
sig
- case sig: TypeRef =>
- TypeRef.withSym(sig.prefix, sig.symbol.asType)
case sig: ClassInfo =>
sig.derivedClassInfo(sig.prefix, sig.classParents, TermRef.withSym(sig.prefix, sourceModule.asTerm))
case _ =>
@@ -423,7 +421,7 @@ class Namer { typer: Typer =>
if (isConstructor) {
// set result type tree to unit, but set the current class as result type of the symbol
typedAheadType(ddef.tpt, defn.UnitType)
- wrapMethType(sym.owner.typeRef.appliedTo(typeParams map (_.symRef)))
+ wrapMethType(sym.owner.typeRef.appliedTo(typeParams map (_.typeRef)))
}
else valOrDefDefSig(ddef, sym, wrapMethType)
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 54e105238..74ad45390 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -718,7 +718,7 @@ class Typer extends Namer with Applications with Implicits {
val mods1 = typedModifiers(mods)
val tpt1 = typedType(tpt)
val rhs1 = typedExpr(rhs, tpt1.tpe)
- val refType = if (sym.exists) sym.symRef else NoType
+ val refType = if (sym.exists) sym.valRef else NoType
cpy.ValDef(vdef, mods1, name, tpt1, rhs1).withType(refType)
}
@@ -729,7 +729,7 @@ class Typer extends Namer with Applications with Implicits {
val vparamss1 = vparamss mapconserve(_ mapconserve (typed(_).asInstanceOf[ValDef]))
val tpt1 = typedType(tpt)
val rhs1 = typedExpr(rhs, tpt1.tpe)
- cpy.DefDef(ddef, mods1, name, tparams1, vparamss1, tpt1, rhs1).withType(sym.symRef)
+ cpy.DefDef(ddef, mods1, name, tparams1, vparamss1, tpt1, rhs1).withType(sym.termRefWithSig)
//todo: make sure dependent method types do not depend on implicits or by-name params
}
@@ -737,7 +737,7 @@ class Typer extends Namer with Applications with Implicits {
val TypeDef(mods, name, rhs) = tdef
val mods1 = typedModifiers(mods)
val rhs1 = typedType(rhs)
- cpy.TypeDef(tdef, mods1, name, rhs1).withType(sym.symRef)
+ cpy.TypeDef(tdef, mods1, name, rhs1).withType(sym.typeRef)
}
def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(implicit ctx: Context) = track("typedClassDef") {
@@ -749,9 +749,9 @@ class Typer extends Namer with Applications with Implicits {
val localDummy = ctx.newLocalDummy(cls, impl.pos)
val body1 = typedStats(body, localDummy)(inClassContext(self1.symbol))
val impl1 = cpy.Template(impl, constr1, parents1, self1, body1)
- .withType(localDummy.symRef)
+ .withType(localDummy.termRef)
- cpy.TypeDef(cdef, mods1, name, impl1).withType(cls.symRef)
+ cpy.TypeDef(cdef, mods1, name, impl1).withType(cls.typeRef)
// todo later: check that
// 1. If class is non-abstract, it is instantiatable:
@@ -764,7 +764,7 @@ class Typer extends Namer with Applications with Implicits {
def typedImport(imp: untpd.Import, sym: Symbol)(implicit ctx: Context): Import = track("typedImport") {
val expr1 = typedExpr(imp.expr, AnySelectionProto)
- cpy.Import(imp, expr1, imp.selectors).withType(sym.symRef)
+ cpy.Import(imp, expr1, imp.selectors).withType(sym.termRef)
}
def typedAnnotated(tree: untpd.Annotated, pt: Type)(implicit ctx: Context): Tree = track("typedAnnotated") {
@@ -787,7 +787,7 @@ class Typer extends Namer with Applications with Implicits {
ctx
}
val stats1 = typedStats(tree.stats, NoSymbol)(packageContext)
- cpy.PackageDef(tree, pid1.asInstanceOf[RefTree], stats1) withType pkg.symRef
+ cpy.PackageDef(tree, pid1.asInstanceOf[RefTree], stats1) withType pkg.valRef
}
def typedUnadapted(initTree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = {