diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-26 14:47:22 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:11 +0100 |
commit | af65672ba1020a55c36ea332f86246254680ab43 (patch) | |
tree | f4fec5fd44e83997e159ea5941c653971543a789 /src/dotty/tools/dotc | |
parent | 252ed1756d6875707e9c09a2b85be5e0f46124a8 (diff) | |
download | dotty-af65672ba1020a55c36ea332f86246254680ab43.tar.gz dotty-af65672ba1020a55c36ea332f86246254680ab43.tar.bz2 dotty-af65672ba1020a55c36ea332f86246254680ab43.zip |
Bugfix: Take account of asSeenFrom in matchingDenotation
When disambiguating overloaded alternatives in matchingSymbol we need
to apply asSeenFrom before comparing signatures. Before this was not done,
and led to a failure of determining the inherited result type of an
apply method in Checking, which in turn led to a type error.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 20 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index cd585dea1..91cf73404 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -120,11 +120,13 @@ object Denotations { /** Is this denotation overloaded? */ final def isOverloaded = isInstanceOf[MultiDenotation] - /** The signature of the denotation */ + /** The signature of the denotation. */ def signature(implicit ctx: Context): Signature - /** Resolve overloaded denotation to pick the one with the given signature */ - def atSignature(sig: Signature)(implicit ctx: Context): SingleDenotation + /** Resolve overloaded denotation to pick the one with the given signature + * when seen from prefix `site`. + */ + def atSignature(sig: Signature, site: Type = NoPrefix)(implicit ctx: Context): SingleDenotation /** The variant of this denotation that's current in the given context. */ def current(implicit ctx: Context): Denotation @@ -207,7 +209,7 @@ object Denotations { */ def matchingDenotation(site: Type, targetType: Type)(implicit ctx: Context): SingleDenotation = if (isOverloaded) - atSignature(targetType.signature).matchingDenotation(site, targetType) + atSignature(targetType.signature, site).matchingDenotation(site, targetType) else if (exists && !site.memberInfo(symbol).matchesLoosely(targetType)) NoDenotation else @@ -343,8 +345,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)(implicit ctx: Context): SingleDenotation = - denot1.atSignature(sig) orElse denot2.atSignature(sig) + def atSignature(sig: Signature, site: Type)(implicit ctx: Context): SingleDenotation = + denot1.atSignature(sig, site) orElse denot2.atSignature(sig, site) def current(implicit ctx: Context): Denotation = derivedMultiDenotation(denot1.current, denot2.current) def altsWith(p: Symbol => Boolean): List[SingleDenotation] = @@ -412,8 +414,10 @@ 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)(implicit ctx: Context): SingleDenotation = - if (sig matches signature) this else NoDenotation + def atSignature(sig: Signature, site: Type)(implicit ctx: Context): SingleDenotation = { + val situated = if (site == NoPrefix) this else asSeenFrom(site) + if (sig matches situated.signature) this else NoDenotation + } // ------ Forming types ------------------------------------------- diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 78c571230..6460be81f 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -603,7 +603,7 @@ class Namer { typer: Typer => } val iResType = iInstInfo.finalResultType.asSeenFrom(site, cls) if (iResType.exists) - typr.println(s"using inherited type; raw: $iRawInfo, inst: $iInstInfo, inherited: $iResType") + typr.println(i"using inherited type for ${mdef.name}; raw: $iRawInfo, inst: $iInstInfo, inherited: $iResType") tp & iResType } } |