aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/References.scala12
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