diff options
author | Martin Odersky <odersky@gmail.com> | 2012-12-22 18:03:56 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-12-22 18:03:56 +0100 |
commit | 01d8a0d90520ea60ead7b2e97cdb79f0a70d6d08 (patch) | |
tree | 6800648695e1c1be408d09c4d99593d0714ecd37 | |
parent | c88f31f494bf4aa5f8210b603d34a5c70a274186 (diff) | |
download | dotty-01d8a0d90520ea60ead7b2e97cdb79f0a70d6d08.tar.gz dotty-01d8a0d90520ea60ead7b2e97cdb79f0a70d6d08.tar.bz2 dotty-01d8a0d90520ea60ead7b2e97cdb79f0a70d6d08.zip |
New atSignature method in References.
-rw-r--r-- | src/dotty/tools/dotc/core/References.scala | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/References.scala b/src/dotty/tools/dotc/core/References.scala index 046fc24a7..a5756ebec 100644 --- a/src/dotty/tools/dotc/core/References.scala +++ b/src/dotty/tools/dotc/core/References.scala @@ -81,8 +81,13 @@ object References { def signature: Signature = throw new UnsupportedOperationException(this.getClass+".signature") + /** Resolve overloaded reference to pick the one with the given signature */ + def atSignature(sig: Signature): Reference + def exists: Boolean = true + def orElse(that: => Reference) = if (this.exists) this else that + /** Form a reference by conjoining with reference `that` */ def & (that: Reference)(implicit ctx: Context): Reference = if (this eq that) this @@ -163,6 +168,8 @@ object References { case class OverloadedRef(ref1: Reference, ref2: Reference) extends Reference { def derivedOverloadedRef(r1: Reference, r2: Reference) = if ((r1 eq ref1) && (r2 eq ref2)) this else OverloadedRef(r1, r2) + def atSignature(sig: Signature): Reference = + ref1.atSignature(sig) orElse ref2.atSignature(sig) } abstract case class SymRef(override val symbol: Symbol, @@ -178,7 +185,7 @@ object References { case mt: MethodType => mt.signature case _ => NullSignature } - if (isType) super.signature else sig(info) + if (isType) NullSignature else sig(info) } def derivedSymRef(s: Symbol, i: Type): SymRef = @@ -186,6 +193,9 @@ object References { protected def copy(s: Symbol, i: Type): SymRef = this + def atSignature(sig: Signature): Reference = + if (sig == signature) this else NoRef + // ------ RefSet ops ---------------------------------------------- def toRef(implicit ctx: Context) = this |