aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-11-01 18:26:02 +0100
committerMartin Odersky <odersky@gmail.com>2013-11-01 18:26:02 +0100
commitf920a3186427e9df2fbac97197f2f11331ef4ef3 (patch)
tree62ab9a95f08650901c91a6ae82361886d67b63a4 /src/dotty/tools/dotc/core/Types.scala
parent1c17a0f83639ddc4b0fd3ffd294a6a97c887aae3 (diff)
downloaddotty-f920a3186427e9df2fbac97197f2f11331ef4ef3.tar.gz
dotty-f920a3186427e9df2fbac97197f2f11331ef4ef3.tar.bz2
dotty-f920a3186427e9df2fbac97197f2f11331ef4ef3.zip
Changed handling of signatures in TermRefs.
Previously, plain TermRefs had signature NotAMethod. The problem is if the TermRef represents an overloaded term and one of the alternatives is NotAMethod. Then creating the alternative will overwrite (via hash-consing) the overloaded ref. Solution: Introduc new pseudo-signature "UnknownSignature" which is given to plain TermRefs. Also, need to be careful now that all members that denote a specific alternative of a possibly overloaded denotation are referenced by a TermRefWithSig, not a plain TermRef. Previously, implicit members did not follow that, which meant that, what worked, worked only by accident. Still to do: Clean up signatures, termref creation methods. Should TermRef.withDenot automatically set the signature?
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index efd8f3594..ba8b4f139 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -528,7 +528,7 @@ object Types {
memberNames(implicitFilter).toList
.flatMap(name => member(name)
.altsWith(_ is Implicit)
- .map(d => TermRef.withSym(this, d.symbol.asTerm).withDenot(d)))
+ .map(d => TermRef.withSig(this, d.symbol.asTerm.name, d.signature).withDenot(d)))
}
/** The info of `sym`, seen as a member of this type. */
@@ -1383,7 +1383,9 @@ object Types {
}
abstract case class TermRef(override val prefix: Type, name: TermName) extends NamedType with SingletonType {
- protected def sig: Signature = NotAMethod
+ protected def sig: Signature = UnknownSignature
+
+ override def signature(implicit ctx: Context): Signature = denot.signature
def isOverloaded(implicit ctx: Context) = denot.isOverloaded
@@ -1440,7 +1442,7 @@ object Types {
*/
final class TermRefWithSignature(prefix: Type, name: TermName, override val sig: Signature) extends TermRef(prefix, name) {
- assert(sig != NotAMethod)
+ assert(sig != UnknownSignature)
override def signature(implicit ctx: Context) = sig
override def loadDenot(implicit ctx: Context): Denotation =
super.loadDenot.atSignature(sig)
@@ -1468,7 +1470,7 @@ object Types {
def withSym(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
withSym(prefix, sym.name, sym)
def withSig(prefix: Type, name: TermName, sig: Signature)(implicit ctx: Context): TermRef =
- if (sig == NotAMethod) apply(prefix, name)
+ if (sig == UnknownSignature) apply(prefix, name)
else unique(new TermRefWithSignature(prefix, name, sig))
}
@@ -1666,15 +1668,15 @@ object Types {
myIsDependent
}
- private[this] var _signature: Signature = _
+ private[this] var mySignature: Signature = _
private[this] var signatureRunId: Int = NoRunId
override def signature(implicit ctx: Context): Signature = {
if (ctx.runId != signatureRunId) {
- _signature = computeSignature
+ mySignature = computeSignature
signatureRunId = ctx.runId
}
- _signature
+ mySignature
}
private def computeSignature(implicit ctx: Context): Signature = {