aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-10 03:41:49 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-10 17:20:41 +0100
commit5d38be773a2083fa2112f5cb688070b867634120 (patch)
tree63eebc91accacb51faade6cf4ece4f271911a13d /src/dotty/tools
parenta63c3db753e8dcc0ed9daa3834ac7a01d6748540 (diff)
downloaddotty-5d38be773a2083fa2112f5cb688070b867634120.tar.gz
dotty-5d38be773a2083fa2112f5cb688070b867634120.tar.bz2
dotty-5d38be773a2083fa2112f5cb688070b867634120.zip
Mover termRef/typeRef and friends up to Denotation.
Needed for implicit search, because some implicits might be UniqueRefs, not SymDenotations
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala30
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala24
-rw-r--r--src/dotty/tools/dotc/core/Types.scala2
3 files changed, 35 insertions, 21 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index f2df71627..e6d5023e5 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -392,6 +392,36 @@ object Denotations {
def atSignature(sig: Signature)(implicit ctx: Context): SingleDenotation =
if (sig matches signature) this else NoDenotation
+ // ------ Forming types -------------------------------------------
+
+ /** The TypeRef representing this type denotation at its original location. */
+ def typeRef(implicit ctx: Context): TypeRef =
+ TypeRef(symbol.owner.thisType, symbol.name.asTypeName, this)
+
+ /** The TermRef representing this term denotation at its original location. */
+ def termRef(implicit ctx: Context): TermRef =
+ TermRef(symbol.owner.thisType, symbol.name.asTermName, this)
+
+ /** The TermRef representing this term denotation at its original location
+ * and at signature `NotAMethod`.
+ */
+ def valRef(implicit ctx: Context): TermRef =
+ TermRef.withSig(symbol.owner.thisType, symbol.name.asTermName, Signature.NotAMethod, this)
+
+ /** 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 termRefWithSig(implicit ctx: Context): TermRef =
+ TermRef.withSig(symbol.owner.thisType, symbol.name.asTermName, signature, this)
+
+ /** 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
+
// ------ Transformations -----------------------------------------
private[this] var myValidFor: Period = Nowhere
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 1904fdbb5..58f148ba5 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -654,34 +654,18 @@ object SymDenotations {
/** The type This(cls), where cls is this class, NoPrefix for all other symbols */
def thisType(implicit ctx: Context): Type = NoPrefix
- /** The TypeRef representing this type denotation at its original location. */
- def typeRef(implicit ctx: Context): TypeRef =
+ override def typeRef(implicit ctx: Context): TypeRef =
TypeRef(owner.thisType, name.asTypeName, this)
- /** The TermRef representing this term denotation at its original location. */
- def termRef(implicit ctx: Context): TermRef =
+ override def termRef(implicit ctx: Context): TermRef =
TermRef(owner.thisType, name.asTermName, this)
- /** The TermRef representing this term denotation at its original location
- * and at signature `NotAMethod`.
- */
- def valRef(implicit ctx: Context): TermRef =
+ override def valRef(implicit ctx: Context): TermRef =
TermRef.withSig(owner.thisType, name.asTermName, Signature.NotAMethod, this)
- /** 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 termRefWithSig(implicit ctx: Context): TermRef =
+ override def termRefWithSig(implicit ctx: Context): TermRef =
TermRef.withSig(owner.thisType, name.asTermName, signature, this)
- /** 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
*/
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index ffc7573b9..e1e3e9c97 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -448,7 +448,7 @@ object Types {
final def implicitMembers(implicit ctx: Context): List[TermRef] = track("implicitMembers") {
memberDenots(implicitFilter,
(name, buf) => buf ++= member(name).altsWith(_ is Implicit))
- .toList.map(_.asInstanceOf[SymDenotation].termRefWithSig)
+ .toList.map(_.termRefWithSig)
}
/** The info of `sym`, seen as a member of this type. */