aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Denotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-09-29 19:15:56 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-29 19:19:31 +0200
commita336ec0a700c0902c74d5318ab47929bc28c5413 (patch)
treee540381184cd067aeb8e7d45fb08c9a131e96379 /src/dotty/tools/dotc/core/Denotations.scala
parent2d9dcecc5757e4bd8659e78a94119c61ebc81a14 (diff)
downloaddotty-a336ec0a700c0902c74d5318ab47929bc28c5413.tar.gz
dotty-a336ec0a700c0902c74d5318ab47929bc28c5413.tar.bz2
dotty-a336ec0a700c0902c74d5318ab47929bc28c5413.zip
Refine atSignature
atSignature should also check result type names, except - if one of the result is a wildcard - a boolean flag relaxed is explicitly set
Diffstat (limited to 'src/dotty/tools/dotc/core/Denotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index cd46918cf..3bab19ea9 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -125,8 +125,9 @@ object Denotations {
/** Resolve overloaded denotation to pick the one with the given signature
* when seen from prefix `site`.
+ * @param relaxed When true, consider only parameter signatures for a match.
*/
- def atSignature(sig: Signature, site: Type = NoPrefix)(implicit ctx: Context): SingleDenotation
+ def atSignature(sig: Signature, site: Type = NoPrefix, relaxed: Boolean = false)(implicit ctx: Context): SingleDenotation
/** The variant of this denotation that's current in the given context, or
* `NotDefinedHereDenotation` if this denotation does not exist at current phase, but
@@ -221,7 +222,7 @@ object Denotations {
*/
def matchingDenotation(site: Type, targetType: Type)(implicit ctx: Context): SingleDenotation =
if (isOverloaded)
- atSignature(targetType.signature, site).matchingDenotation(site, targetType)
+ atSignature(targetType.signature, site, relaxed = true).matchingDenotation(site, targetType)
else if (exists && !site.memberInfo(symbol).matchesLoosely(targetType))
NoDenotation
else
@@ -398,8 +399,8 @@ object Denotations {
final def validFor = denot1.validFor & denot2.validFor
final def isType = false
final def signature(implicit ctx: Context) = Signature.OverloadedSignature
- def atSignature(sig: Signature, site: Type)(implicit ctx: Context): SingleDenotation =
- denot1.atSignature(sig, site) orElse denot2.atSignature(sig, site)
+ def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): SingleDenotation =
+ denot1.atSignature(sig, site, relaxed) orElse denot2.atSignature(sig, site, relaxed)
def currentIfExists(implicit ctx: Context): Denotation =
derivedMultiDenotation(denot1.currentIfExists, denot2.currentIfExists)
def current(implicit ctx: Context): Denotation =
@@ -469,9 +470,12 @@ object Denotations {
def accessibleFrom(pre: Type, superAccess: Boolean)(implicit ctx: Context): Denotation =
if (!symbol.exists || symbol.isAccessibleFrom(pre, superAccess)) this else NoDenotation
- def atSignature(sig: Signature, site: Type)(implicit ctx: Context): SingleDenotation = {
+ def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): SingleDenotation = {
val situated = if (site == NoPrefix) this else asSeenFrom(site)
- if (sig matches situated.signature) this else NoDenotation
+ val matches =
+ if (relaxed) sig.matches(situated.signature)
+ else sig.matchesFully(situated.signature)
+ if (matches) this else NoDenotation
}
def matches(other: SingleDenotation)(implicit ctx: Context): Boolean =