summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala37
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala5
7 files changed, 28 insertions, 28 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index c80aaea160..b0bd9977a8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -550,23 +550,18 @@ trait ContextErrors {
def ModuleUsingCompanionClassDefaultArgsErrror(tree: Tree) =
NormalTypeError(tree, "module extending its companion class cannot use default constructor arguments")
- def NotEnoughArgsError(tree: Tree, fun0: Tree, missing0: List[Symbol]) = {
- def notEnoughArgumentsMsg(fun: Tree, missing: List[Symbol]) = {
- val suffix = {
- if (missing.isEmpty) ""
- else {
- val keep = missing take 3 map (_.name)
- ".\nUnspecified value parameter%s %s".format(
- if (missing.tail.isEmpty) "" else "s",
- if ((missing drop 3).nonEmpty) (keep :+ "...").mkString(", ")
- else keep.mkString("", ", ", ".")
- )
- }
+ def NotEnoughArgsError(tree: Tree, fun: Tree, missing: List[Symbol]) = {
+ val notEnoughArgumentsMsg = {
+ val suffix = if (missing.isEmpty) "" else {
+ val keep = missing take 3 map (_.name)
+ val ess = if (missing.tail.isEmpty) "" else "s"
+ f".%nUnspecified value parameter$ess ${
+ keep.mkString("", ", ", if ((missing drop 3).nonEmpty) "..." else ".")
+ }"
}
-
- "not enough arguments for " + treeSymTypeMsg(fun) + suffix
+ s"not enough arguments for ${ treeSymTypeMsg(fun) }$suffix"
}
- NormalTypeError(tree, notEnoughArgumentsMsg(fun0, missing0))
+ NormalTypeError(tree, notEnoughArgumentsMsg)
}
//doTypedApply - patternMode
@@ -632,12 +627,16 @@ trait ContextErrors {
//adapt
def MissingArgsForMethodTpeError(tree: Tree, meth: Symbol) = {
+ val f = meth.name
+ val paf = s"$f(${ meth.asMethod.paramLists map (_ map (_ => "_") mkString ",") mkString ")(" })"
+ val advice = s"""
+ |Unapplied methods are only converted to functions when a function type is expected.
+ |You can make this conversion explicit by writing `$f _` or `$paf` instead of `$f`.""".stripMargin
val message =
if (meth.isMacro) MacroTooFewArgumentListsMessage
- else "missing arguments for " + meth.fullLocationString + (
- if (meth.isConstructor) ""
- else ";\nfollow this method with `_' if you want to treat it as a partially applied function"
- )
+ else s"""missing argument list for ${meth.fullLocationString}${
+ if (!meth.isConstructor) advice else ""
+ }"""
issueNormalTypeError(tree, message)
setError(tree)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 7c931600e5..4c840818da 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -1495,7 +1495,7 @@ object ContextMode {
final val TypeConstructorAllowed: ContextMode = 1 << 16
/** TODO: The "sticky modes" are EXPRmode, PATTERNmode, TYPEmode.
- * To mimick the sticky mode behavior, when captain stickyfingers
+ * To mimic the sticky mode behavior, when captain stickyfingers
* comes around we need to propagate those modes but forget the other
* context modes which were once mode bits; those being so far the
* ones listed here.
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 3274c86072..7ce945dd6c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -846,7 +846,7 @@ trait Implicits {
errors.collectFirst { case err: DivergentImplicitTypeError => err } foreach saveDivergent
if (search.isDivergent && divergentError.isEmpty) {
- // Divergence triggered by `i` at this level of the implicit serach. We haven't
+ // Divergence triggered by `i` at this level of the implicit search. We haven't
// seen divergence so far, we won't issue this error just yet, and instead temporarily
// treat `i` as a failed candidate.
saveDivergent(DivergentImplicitTypeError(tree, pt, i.sym))
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index f90e32ce8a..f3856db552 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -436,7 +436,7 @@ trait MethodSynthesis {
if (tree.symbol.owner.isTrait || hasUnitType(basisSym)) rhs1
else gen.mkAssignAndReturn(basisSym, rhs1)
)
- derivedSym setPos tree.pos // cannot set it at createAndEnterSymbol because basisSym can possible stil have NoPosition
+ derivedSym setPos tree.pos // cannot set it at createAndEnterSymbol because basisSym can possibly still have NoPosition
val ddefRes = DefDef(derivedSym, new ChangeOwnerAndModuleClassTraverser(basisSym, derivedSym)(body))
// ValDef will have its position focused whereas DefDef will have original correct rangepos
// ideally positions would be correct at the creation time but lazy vals are really a special case
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 77c49a862a..c1655467e9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -204,7 +204,7 @@ trait Namers extends MethodSynthesis {
}
// FIXME - this logic needs to be thoroughly explained
- // and justified. I know it's wrong with repect to package
+ // and justified. I know it's wrong with respect to package
// objects, but I think it's also wrong in other ways.
protected def conflict(newS: Symbol, oldS: Symbol) = (
( !oldS.isSourceMethod
@@ -1106,7 +1106,7 @@ trait Namers extends MethodSynthesis {
* As a first side effect, this method assigns a MethodType constructed using this
* return type to `meth`. This allows omitting the result type for recursive methods.
*
- * As another side effect, this method also assigns paramter types from the overridden
+ * As another side effect, this method also assigns parameter types from the overridden
* method to parameters of `meth` that have missing types (the parser accepts missing
* parameter types under -Yinfer-argument-types).
*/
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
index 8a66c7d274..a702b3cdf5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
@@ -305,7 +305,7 @@ trait PatternTypers {
// clearing the type is necessary so that ref will be stabilized; see bug 881
val fun1 = typedPos(fun.pos)(Apply(Select(fun.clearType(), unapplyMethod), unapplyArgTree :: Nil))
- def makeTypedUnApply() = {
+ def makeTypedUnapply() = {
// the union of the expected type and the inferred type of the argument to unapply
val glbType = glb(ensureFullyDefined(pt) :: unapplyArg.tpe_* :: Nil)
val wrapInTypeTest = canRemedy && !(fun1.symbol.owner isNonBottomSubClass ClassTagClass)
@@ -325,7 +325,7 @@ trait PatternTypers {
if (isBlackbox(unapplyMethod)) duplErrorTree(BlackboxExtractorExpansion(tree))
else duplErrorTree(WrongShapeExtractorExpansion(tree))
} else
- makeTypedUnApply()
+ makeTypedUnapply()
}
def wrapClassTagUnapply(uncheckedPattern: Tree, classTagExtractor: Tree, pt: Type): Tree = {
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 059981aa37..5f2643cb25 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -309,6 +309,7 @@ trait TypeDiagnostics {
// save the name because it will be mutated until it has been
// distinguished from the other types in the same error message
private val savedName = sym.name
+ private var postQualifiedWith: List[Symbol] = Nil
def restoreName() = sym.name = savedName
def modifyName(f: String => String) = sym setName newTypeName(f(sym.name.toString))
@@ -317,12 +318,12 @@ trait TypeDiagnostics {
*/
def qualifyDefaultNamespaces() = {
val intersect = Set(trueOwner, aliasOwner) intersect UnqualifiedOwners
- if (intersect.nonEmpty) preQualify()
+ if (intersect.nonEmpty && tp.typeSymbolDirect.name == tp.typeSymbol.name) preQualify()
}
// functions to manipulate the name
def preQualify() = modifyName(trueOwner.fullName + "." + _)
- def postQualify() = modifyName(_ + "(in " + trueOwner + ")")
+ def postQualify() = if (!(postQualifiedWith contains trueOwner)) { postQualifiedWith ::= trueOwner; modifyName(_ + "(in " + trueOwner + ")") }
def typeQualify() = if (sym.isTypeParameterOrSkolem) postQualify()
def nameQualify() = if (trueOwner.isPackageClass) preQualify() else postQualify()