aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Implicits.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-06 07:43:43 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-06 07:43:43 +0100
commit7b30d5b7a9fe7d89a252d8d9a07fd4c009e49a0d (patch)
tree86ac57d6e04b549516fe6c1c9e817419120c57d6 /src/dotty/tools/dotc/typer/Implicits.scala
parent3fa986d52281fb3ece27e825d56e2723ae97d84b (diff)
downloaddotty-7b30d5b7a9fe7d89a252d8d9a07fd4c009e49a0d.tar.gz
dotty-7b30d5b7a9fe7d89a252d8d9a07fd4c009e49a0d.tar.bz2
dotty-7b30d5b7a9fe7d89a252d8d9a07fd4c009e49a0d.zip
Exclude inaccessible definitions from contextual implicit search.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Implicits.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index dd06782ec..2e8598c64 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -41,7 +41,9 @@ object Implicits {
/** Return those references in `refs` that are compatible with type `pt`. */
protected def filterMatching(pt: Type)(implicit ctx: Context): List[TermRef] = track("filterMatching") {
- def refMatches(ref: TermRef)(implicit ctx: Context) = isCompatible(normalize(ref, pt), pt)
+ def refMatches(ref: TermRef)(implicit ctx: Context) =
+ (ref.symbol isAccessibleFrom ref.prefix) && isCompatible(normalize(ref, pt), pt)
+
refs filter (refMatches(_)(ctx.fresh.withExploreTyperState)) // create a defensive copy of ctx to avoid constraint pollution
}
@@ -354,7 +356,7 @@ trait Implicits { self: Typer =>
}
if (ctx.typerState.reporter.hasErrors)
nonMatchingImplicit(ref)
- else if (contextual && !refMatches(shadowing)) {
+ else if (contextual && !shadowing.tpe.isError && !refMatches(shadowing)) {
println(i"SHADOWING $ref is shadowed by $shadowing")
shadowedImplicit(ref, methPart(shadowing).tpe)
}