summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-10-17 21:01:31 +0000
committerMartin Odersky <odersky@gmail.com>2010-10-17 21:01:31 +0000
commitc39f26382dddaa7e000022704792c813f8bf7f2b (patch)
tree0b23f4558a82f6519cb6715147fb25b6df7d2b8f /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent491ecd7b8b2e5a0ee1f185f26042a80e11e46568 (diff)
downloadscala-c39f26382dddaa7e000022704792c813f8bf7f2b.tar.gz
scala-c39f26382dddaa7e000022704792c813f8bf7f2b.tar.bz2
scala-c39f26382dddaa7e000022704792c813f8bf7f2b.zip
Closes #3871.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index fa62e24d96..2c8d1c845f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3664,9 +3664,12 @@ trait Typers { self: Analyzer =>
def ambiguousError(msg: String) =
error(tree.pos, "reference to " + name + " is ambiguous;\n" + msg)
- var defSym: Symbol = tree.symbol // the directly found symbol
- var pre: Type = NoPrefix // the prefix type of defSym, if a class member
- var qual: Tree = EmptyTree // the qualifier tree if transformed tree is a select
+ var defSym: Symbol = tree.symbol // the directly found symbol
+ var pre: Type = NoPrefix // the prefix type of defSym, if a class member
+ var qual: Tree = EmptyTree // the qualifier tree if transformed tree is a select
+ var inaccessibleSym: Symbol = NoSymbol // the first symbol that was found but that was discarded
+ // for being inaccessible; used for error reporting
+ var inaccessibleExplanation: String = ""
// A symbol qualifies if it exists and is not stale. Stale symbols
// are made to disappear here. In addition,
@@ -3699,7 +3702,13 @@ trait Typers { self: Analyzer =>
cx = cx.enclClass
defSym = pre.member(name) filter (
sym => qualifies(sym) && context.isAccessible(sym, pre, false))
- if (defSym == NoSymbol) cx = cx.outer
+ if (defSym == NoSymbol) {
+ if (inaccessibleSym eq NoSymbol) {
+ inaccessibleSym = pre.member(name) filter qualifies
+ inaccessibleExplanation = analyzer.lastAccessCheckDetails
+ }
+ cx = cx.outer
+ }
}
}
@@ -3769,7 +3778,11 @@ trait Typers { self: Analyzer =>
if (settings.debug.value) {
log(context.imports)//debug
}
- error(tree.pos, "not found: "+decodeWithNamespace(name))
+ if (inaccessibleSym eq NoSymbol) {
+ error(tree.pos, "not found: "+decodeWithNamespace(name))
+ } else accessError(
+ tree, inaccessibleSym, context.enclClass.owner.thisType,
+ inaccessibleExplanation)
defSym = context.owner.newErrorSymbol(name)
}
}