aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core')
-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
5 files changed, 33 insertions, 30 deletions
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()