summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Infer.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Infer.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index d198303d66..296e555559 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -234,6 +234,14 @@ trait Infer {
def explainTypes(tp1: Type, tp2: Type) =
withDisambiguation(tp1, tp2)(global.explainTypes(tp1, tp2))
+ def accessError(tree: Tree, sym: Symbol, pre: Type, explanation: String): Tree = {
+ val realsym = underlying(sym)
+
+ errorTree(tree, realsym + realsym.locationString + " cannot be accessed in " +
+ (if (sym.isClassConstructor) context.enclClass.owner else pre.widen) +
+ explanation)
+ }
+
/* -- Tests & Checks---------------------------------------------------- */
/** Check that <code>sym</code> is defined and accessible as a member of
@@ -250,19 +258,16 @@ trait Infer {
if (context.unit != null)
context.unit.depends += sym.toplevelClass
- var sym1 = sym filter (alt => context.isAccessible(alt, pre, site.isInstanceOf[Super]))
+ val sym1 = sym filter (alt => context.isAccessible(alt, pre, site.isInstanceOf[Super]))
// Console.println("check acc " + (sym, sym1) + ":" + (sym.tpe, sym1.tpe) + " from " + pre);//DEBUG
- if (sym1 == NoSymbol && sym.isJavaDefined && context.unit.isJava) // don't try to second guess Java; see #4402
- sym1 = sym
-
if (sym1 == NoSymbol) {
if (settings.debug.value) {
Console.println(context)
Console.println(tree)
Console.println("" + pre + " " + sym.owner + " " + context.owner + " " + context.outer.enclClass.owner + " " + sym.owner.thisType + (pre =:= sym.owner.thisType))
}
- new AccessError(tree, sym, pre,
+ accessError(tree, sym, pre,
if (settings.check.isDefault) {
analyzer.lastAccessCheckDetails
} else {
@@ -290,10 +295,10 @@ trait Infer {
if (settings.debug.value) ex.printStackTrace
val sym2 = underlying(sym1)
val itype = pre.memberType(sym2)
- new AccessError(tree, sym, pre,
+ accessError(tree, sym, pre,
"\n because its instance type "+itype+
(if ("malformed type: "+itype.toString==ex.msg) " is malformed"
- else " contains a "+ex.msg)).emit()
+ else " contains a "+ex.msg))
ErrorType
}
if (pre.isInstanceOf[SuperType])
@@ -1692,21 +1697,6 @@ trait Infer {
// Side effects tree with symbol and type
tree setSymbol resSym setType resTpe
}
-
- case class AccessError(tree: Tree, sym: Symbol, pre: Type, explanation: String) extends Tree {
- override def pos = tree.pos
- override def hasSymbol = tree.hasSymbol
- override def symbol = tree.symbol
- override def symbol_=(x: Symbol) = tree.symbol = x
- setError(this)
-
- def emit(): Tree = {
- val realsym = underlying(sym)
- errorTree(tree, realsym + realsym.locationString + " cannot be accessed in " +
- (if (sym.isClassConstructor) context.enclClass.owner else pre.widen) +
- explanation)
- }
- }
}
}