aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-11-25 12:29:58 +0100
committerMartin Odersky <odersky@gmail.com>2013-11-25 12:34:36 +0100
commit19d92a561b06dc257a71ba0f330fe4e594d1fd06 (patch)
treeab0f8ec2fa108ace92601ff45d04a9b1b02369c1 /src/dotty/tools/dotc/core/Types.scala
parent6d3415d23ffcb9db63452d11fd38fdcd8e8b7438 (diff)
downloaddotty-19d92a561b06dc257a71ba0f330fe4e594d1fd06.tar.gz
dotty-19d92a561b06dc257a71ba0f330fe4e594d1fd06.tar.bz2
dotty-19d92a561b06dc257a71ba0f330fe4e594d1fd06.zip
Getting rid of UnknownSignature
I believe the logic is now clearer. Good to have one magic value less.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 02577ffd2..c1a7bced5 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1135,12 +1135,20 @@ object Types {
*/
protected def newLikeThis(prefix: Type)(implicit ctx: Context): NamedType =
NamedType(prefix, name)
+
+ override def equals(that: Any) = that match {
+ case that: NamedType =>
+ this.name == that.name &&
+ this.prefix == that.prefix &&
+ !that.isInstanceOf[TermRefWithSignature]
+ case _ =>
+ false
+ }
+ override def computeHash = doHash(name, prefix)
}
abstract case class TermRef(override val prefix: Type, name: TermName) extends NamedType with SingletonType {
- protected def sig: Signature = UnknownSignature
-
override def underlying(implicit ctx: Context): Type = {
val d = denot
if (d.isOverloaded) NoType else d.info
@@ -1158,9 +1166,18 @@ object Types {
def altsWith(p: Symbol => Boolean)(implicit ctx: Context): List[TermRef] =
denot.altsWith(p) map rewrap
+ }
+ abstract case class TypeRef(override val prefix: Type, name: TypeName) extends NamedType
+
+ final class TermRefWithSignature(prefix: Type, name: TermName, val sig: Signature) extends TermRef(prefix, name) {
+ override def signature(implicit ctx: Context) = sig
+ override def loadDenot(implicit ctx: Context): Denotation =
+ super.loadDenot.atSignature(sig)
+ override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRef =
+ TermRef.withSig(prefix, name, sig)
override def equals(that: Any) = that match {
- case that: TermRef =>
+ case that: TermRefWithSignature =>
this.prefix == that.prefix &&
this.name == that.name &&
this.sig == that.sig
@@ -1170,28 +1187,6 @@ object Types {
override def computeHash = doHash((name, sig), prefix)
}
- abstract case class TypeRef(override val prefix: Type, name: TypeName) extends NamedType {
-
- override def equals(that: Any) = that match {
- case that: TypeRef =>
- this.prefix == that.prefix &&
- this.name == that.name
- case _ =>
- false
- }
- //assert(name.toString != "scala$collection$LinearSeqLike$$Repr", s"sel pre = $prefix")
- override def computeHash = doHash(name, prefix)
- }
-
- final class TermRefWithSignature(prefix: Type, name: TermName, override val sig: Signature) extends TermRef(prefix, name) {
- assert(sig != UnknownSignature)
- override def signature(implicit ctx: Context) = sig
- override def loadDenot(implicit ctx: Context): Denotation =
- super.loadDenot.atSignature(sig)
- override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRef =
- TermRef.withSig(prefix, name, sig)
- }
-
final class CachedTermRef(prefix: Type, name: TermName) extends TermRef(prefix, name)
final class CachedTypeRef(prefix: Type, name: TypeName) extends TypeRef(prefix, name)
@@ -1209,8 +1204,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 == UnknownSignature) apply(prefix, name)
- else unique(new TermRefWithSignature(prefix, name, sig))
+ unique(new TermRefWithSignature(prefix, name, sig))
}
object TypeRef {