summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2011-08-11 21:40:15 +0000
committermichelou <michelou@epfl.ch>2011-08-11 21:40:15 +0000
commitfebd8857dda25f79704031e5bd2005b7271025c1 (patch)
tree22485ae199b868d739c40df3fb74cf7d77e248cb
parente4288e5143dc85e9b22d881bf5b19996597722f6 (diff)
downloadscala-febd8857dda25f79704031e5bd2005b7271025c1.tar.gz
scala-febd8857dda25f79704031e5bd2005b7271025c1.tar.bz2
scala-febd8857dda25f79704031e5bd2005b7271025c1.zip
fixed text in error message
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala85
-rw-r--r--test/files/neg/bug3714-neg.check4
-rw-r--r--test/files/neg/protected-constructors.check6
-rw-r--r--test/files/neg/protected-static-fail.check4
-rw-r--r--test/files/neg/t3934.check2
5 files changed, 38 insertions, 63 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 44c28cf2f5..bc7c0ad53a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -10,8 +10,7 @@ import symtab.Flags._
import scala.collection.mutable.ListBuffer
import annotation.tailrec
-/** This trait ...
- *
+/**
* @author Martin Odersky
* @version 1.0
*/
@@ -36,13 +35,13 @@ trait Contexts { self: Analyzer =>
var lastAccessCheckDetails: String = ""
/** List of symbols to import from in a root context. Typically that
- * is java.lang, scala, and scala.Predef, in that order. Exceptions:
+ * is `java.lang`, `scala`, and [[scala.Predef]], in that order. Exceptions:
*
- * -- if -Yno-imports is given, nothing is imported
- * -- if the unit is java defined, only java.lang is imported
- * -- if -Yno-predef is given, if the unit has an import of Predef
- * among its leading imports, or if the unit is scala.ScalaObject
- * or scala.Predef, Predef is not imported.
+ * - if option `-Yno-imports` is given, nothing is imported
+ * - if the unit is java defined, only `java.lang` is imported
+ * - if option `-Yno-predef` is given, if the unit has an import of Predef
+ * among its leading imports, or if the unit is [[scala.ScalaObject]]
+ * or [[scala.Predef]], `Predef` is not imported.
*/
protected def rootImports(unit: CompilationUnit, tree: Tree): List[Symbol] = {
import definitions._
@@ -128,12 +127,11 @@ trait Contexts { self: Analyzer =>
var typingIndentLevel: Int = 0
def typingIndent = " " * typingIndentLevel
- def undetparamsString = if (undetparams.isEmpty) "" else undetparams.mkString("undetparams=", ", ", "")
+ def undetparamsString =
+ if (undetparams.isEmpty) ""
+ else undetparams.mkString("undetparams=", ", ", "")
def undetparams = _undetparams
- def undetparams_=(ps: List[Symbol]) = {
- //System.out.println("undetparams = " + ps);//debug
- _undetparams = ps
- }
+ def undetparams_=(ps: List[Symbol]) = { _undetparams = ps }
def extractUndetparams() = {
val tparams = undetparams
@@ -155,14 +153,6 @@ trait Contexts { self: Analyzer =>
finally implicitsEnabled = saved
}
- /**
- * @param unit ...
- * @param tree ...
- * @param owner ...
- * @param scope ...
- * @param imports ...
- * @return ...
- */
def make(unit: CompilationUnit, tree: Tree, owner: Symbol,
scope: Scope, imports: List[ImportInfo]): Context = {
val c = new Context
@@ -218,13 +208,12 @@ trait Contexts { self: Analyzer =>
def makeNewImport(imp: Import): Context =
make(unit, imp, owner, scope, new ImportInfo(imp, depth) :: imports)
- def make(tree: Tree, owner: Symbol, scope: Scope): Context = {
+ def make(tree: Tree, owner: Symbol, scope: Scope): Context =
if (tree == this.tree && owner == this.owner && scope == this.scope) this
else make0(tree, owner, scope)
- }
- private def make0(tree : Tree, owner : Symbol, scope : Scope) : Context = {
+
+ private def make0(tree: Tree, owner: Symbol, scope: Scope): Context =
make(unit, tree, owner, scope, imports)
- }
def makeNewScope(tree: Tree, owner: Symbol): Context =
make(tree, owner, new Scope(scope))
@@ -274,12 +263,10 @@ trait Contexts { self: Analyzer =>
argContext
}
- private def diagString =
- if (diagnostic.isEmpty) ""
- else diagnostic.mkString("\n","\n", "")
-
private def addDiagString(msg: String) = {
- val ds = diagString
+ val ds =
+ if (diagnostic.isEmpty) ""
+ else diagnostic.mkString("\n","\n", "")
if (msg endsWith ds) msg else msg + ds
}
@@ -306,13 +293,6 @@ trait Contexts { self: Analyzer =>
if (reportGeneralErrors) unit.warning(pos, msg)
}
- /**
- * @param pos ...
- * @param pre ...
- * @param sym1 ...
- * @param sym2 ...
- * @param rest ...
- */
def ambiguousError(pos: Position, pre: Type, sym1: Symbol, sym2: Symbol, rest: String) {
val (reportPos, msg) = (
if (sym1.hasDefaultFlag && sym2.hasDefaultFlag && sym1.enclClass == sym2.enclClass) {
@@ -385,8 +365,8 @@ trait Contexts { self: Analyzer =>
c
}
- /** Return closest enclosing context that defines a subclass of `clazz` or a companion
- * object thereof, or NoContext if no such context exists
+ /** Return the closest enclosing context that defines a subclass of `clazz`
+ * or a companion object thereof, or `NoContext` if no such context exists.
*/
def enclosingSubClassContext(clazz: Symbol): Context = {
var c = this.enclClass
@@ -395,13 +375,8 @@ trait Contexts { self: Analyzer =>
c
}
- /** Is <code>sym</code> accessible as a member of tree `site` with type
- * <code>pre</code> in current context?
- *
- * @param sym ...
- * @param pre ...
- * @param superAccess ...
- * @return ...
+ /** Is `sym` accessible as a member of tree `site` with type
+ * `pre` in current context?
*/
def isAccessible(sym: Symbol, pre: Type, superAccess: Boolean = false): Boolean = {
lastAccessCheckDetails = ""
@@ -452,7 +427,8 @@ trait Contexts { self: Analyzer =>
if (c == NoContext)
lastAccessCheckDetails =
"\n Access to protected "+target+" not permitted because"+
- "\n "+"enclosing class "+this.enclClass.owner+this.enclClass.owner.locationString+" is not a subclass of "+
+ "\n "+"enclosing "+this.enclClass.owner+
+ this.enclClass.owner.locationString+" is not a subclass of "+
"\n "+sym.owner+sym.owner.locationString+" where target is defined"
c != NoContext &&
{
@@ -562,7 +538,6 @@ trait Contexts { self: Analyzer =>
}
def implicitss: List[List[ImplicitInfo]] = {
-
if (implicitsRunId != currentRunId) {
implicitsRunId = currentRunId
implicitsCache = List()
@@ -603,8 +578,8 @@ trait Contexts { self: Analyzer =>
def lookup(name: Name, expectedOwner: Symbol) = {
var res: Symbol = NoSymbol
var ctx = this
- while(res == NoSymbol && ctx.outer != ctx) {
- val s = ctx.scope.lookup(name)
+ while (res == NoSymbol && ctx.outer != ctx) {
+ val s = ctx.scope lookup name
if (s != NoSymbol && s.owner == expectedOwner)
res = s
else
@@ -612,21 +587,21 @@ trait Contexts { self: Analyzer =>
}
res
}
- }
+ } //class Context
+
class ImportInfo(val tree: Import, val depth: Int) {
/** The prefix expression */
def qual: Tree = tree.symbol.info match {
case ImportType(expr) => expr
case ErrorType => tree setType NoType // fix for #2870
- case _ => throw new FatalError("symbol " + tree.symbol + " has bad type: " + tree.symbol.info);//debug
+ case _ => throw new FatalError("symbol " + tree.symbol + " has bad type: " + tree.symbol.info) //debug
}
/** Is name imported explicitly, not via wildcard? */
def isExplicitImport(name: Name): Boolean =
tree.selectors exists (_.rename == name.toTermName)
- /** The symbol with name <code>name</code> imported from import clause
- * <code>tree</code>.
+ /** The symbol with name `name` imported from import clause `tree`.
*/
def importedSymbol(name: Name): Symbol = {
var result: Symbol = NoSymbol
@@ -651,7 +626,7 @@ trait Contexts { self: Analyzer =>
private def transformImport(selectors: List[ImportSelector], sym: Symbol): List[Symbol] = selectors match {
case List() => List()
case List(ImportSelector(nme.WILDCARD, _, _, _)) => List(sym)
- case ImportSelector(from, _, to, _) :: _ if (from == sym.name) =>
+ case ImportSelector(from, _, to, _) :: _ if from == sym.name =>
if (to == nme.WILDCARD) List()
else { val sym1 = sym.cloneSymbol; sym1.name = to; List(sym1) }
case _ :: rest => transformImport(rest, sym)
diff --git a/test/files/neg/bug3714-neg.check b/test/files/neg/bug3714-neg.check
index fab6623001..48420514ec 100644
--- a/test/files/neg/bug3714-neg.check
+++ b/test/files/neg/bug3714-neg.check
@@ -1,12 +1,12 @@
bug3714-neg.scala:17: error: value break in class BreakImpl cannot be accessed in BreakImpl
Access to protected value break not permitted because
- enclosing class object Test is not a subclass of
+ enclosing object Test is not a subclass of
class BreakImpl where target is defined
case b: BreakImpl => b.break
^
bug3714-neg.scala:25: error: value break in class BreakImpl cannot be accessed in BreakImpl
Access to protected value break not permitted because
- enclosing class object Test is not a subclass of
+ enclosing object Test is not a subclass of
class BreakImpl where target is defined
case b: BreakImpl => b.break
^
diff --git a/test/files/neg/protected-constructors.check b/test/files/neg/protected-constructors.check
index d6b9221a49..3add24c089 100644
--- a/test/files/neg/protected-constructors.check
+++ b/test/files/neg/protected-constructors.check
@@ -3,19 +3,19 @@ protected-constructors.scala:17: error: too many arguments for constructor Foo1:
^
protected-constructors.scala:18: error: constructor Foo2 in class Foo2 cannot be accessed in object P
Access to protected constructor Foo2 not permitted because
- enclosing class object P in package hungus is not a subclass of
+ enclosing object P in package hungus is not a subclass of
class Foo2 in package dingus where target is defined
val foo2 = new Foo2("abc")
^
protected-constructors.scala:19: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding
Access to protected class Foo3 not permitted because
- enclosing class object P in package hungus is not a subclass of
+ enclosing object P in package hungus is not a subclass of
object Ding in package dingus where target is defined
val foo3 = new Ding.Foo3("abc")
^
protected-constructors.scala:15: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding
Access to protected class Foo3 not permitted because
- enclosing class object P in package hungus is not a subclass of
+ enclosing object P in package hungus is not a subclass of
object Ding in package dingus where target is defined
class Bar3 extends Ding.Foo3("abc")
^
diff --git a/test/files/neg/protected-static-fail.check b/test/files/neg/protected-static-fail.check
index 2f8a0caeab..e149bc016f 100644
--- a/test/files/neg/protected-static-fail.check
+++ b/test/files/neg/protected-static-fail.check
@@ -3,13 +3,13 @@ S.scala:5: error: method f in object J cannot be accessed in object bippy.J
^
S.scala:6: error: method f1 in object S1 cannot be accessed in object bippy.S1
Access to protected method f1 not permitted because
- enclosing class object Test in package bippy is not a subclass of
+ enclosing object Test in package bippy is not a subclass of
object S1 in package bippy where target is defined
S1.f1()
^
S.scala:8: error: method f2 in class S2 cannot be accessed in bippy.S2
Access to protected method f2 not permitted because
- enclosing class object Test in package bippy is not a subclass of
+ enclosing object Test in package bippy is not a subclass of
class S2 in package bippy where target is defined
x.f2()
^
diff --git a/test/files/neg/t3934.check b/test/files/neg/t3934.check
index ebc6dfb876..405ed2e879 100644
--- a/test/files/neg/t3934.check
+++ b/test/files/neg/t3934.check
@@ -1,6 +1,6 @@
t3934.scala:15: error: method f2 in class J cannot be accessed in test.J
Access to protected method f2 not permitted because
- enclosing class class S1 in package nest is not a subclass of
+ enclosing class S1 in package nest is not a subclass of
class J in package test where target is defined
def g2(x: J) = x.f2()
^