diff options
Diffstat (limited to 'src/compiler/scala')
16 files changed, 49 insertions, 36 deletions
diff --git a/src/compiler/scala/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/reflect/quasiquotes/Reifiers.scala index 8462debe21..b2002a07ea 100644 --- a/src/compiler/scala/reflect/quasiquotes/Reifiers.scala +++ b/src/compiler/scala/reflect/quasiquotes/Reifiers.scala @@ -317,7 +317,7 @@ trait Reifiers { self: Quasiquotes => * Reification of non-trivial list is done in two steps: * * 1. split the list into groups where every placeholder is always - * put in a group of its own and all subsquent non-holeMap are + * put in a group of its own and all subsequent non-holeMap are * grouped together; element is considered to be a placeholder if it's * in the domain of the fill function; * diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala index ca7d8776d4..cb523edfe5 100644 --- a/src/compiler/scala/tools/nsc/Properties.scala +++ b/src/compiler/scala/tools/nsc/Properties.scala @@ -12,8 +12,16 @@ object Properties extends scala.util.PropertiesTrait { protected def pickJarBasedOn = classOf[Global] // settings based on jar properties, falling back to System prefixed by "scala." + + // messages to display at startup or prompt, format string with string parameters + // Scala version, Java version, JVM name def residentPromptString = scalaPropOrElse("resident.prompt", "\nnsc> ") def shellPromptString = scalaPropOrElse("shell.prompt", "%nscala> ") + def shellWelcomeString = scalaPropOrElse("shell.welcome", + """Welcome to Scala %1$#s (%3$s, Java %2$s). + |Type in expressions for evaluation. Or try :help.""".stripMargin + ) + // message to display at EOF (which by default ends with // a newline so as not to break the user's terminal) def shellInterruptedString = scalaPropOrElse("shell.interrupted", f":quit$lineSeparator") diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 0575b9703e..bf53c47e9a 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -233,7 +233,7 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL { } /** Return the synchronized part of the double-checked locking idiom around the syncBody tree. It guards with `cond` and - * synchronizez on `clazz.this`. Additional statements can be included after initialization, + * synchronizes on `clazz.this`. Additional statements can be included after initialization, * (outside the synchronized block). * * The idiom works only if the condition is using a volatile field. diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 076f84ce7a..351a8e33d3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -86,7 +86,7 @@ trait Opcodes { self: ICodes => * Each case subclass will represent a specific operation. */ abstract class Instruction extends Cloneable { - // Vlad: I used these for checking the quality of the implementation, and we should regularely run a build with them + // Vlad: I used these for checking the quality of the implementation, and we should regularly run a build with them // enabled. But for production these should definitely be disabled, unless we enjoy getting angry emails from Greg :) //if (!this.isInstanceOf[opcodes.LOAD_EXCEPTION]) // assert(consumed == consumedTypes.length) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala index 7f0aaa7305..8720da84e8 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala @@ -648,7 +648,7 @@ abstract class BTypes { * JVMS 4.7.7: the attribute must be present "if and only if it represents a local class * or an anonymous class" (i.e. not for member classes). * - * The attribute is mis-named, it should be called "EnclosingClass". It has to be defined for all + * The attribute is misnamed, it should be called "EnclosingClass". It has to be defined for all * local and anonymous classes, no matter if there is an enclosing method or not. Accordingly, the * "class" field (see below) must be always defined, while the "method" field may be null. * @@ -798,7 +798,7 @@ abstract class BTypes { * 2. The ClassBType should be built from a classfile, but the class could not be found on the * compilation classpath. * - * Note that all ClassBTypes required in a non-optimzied run are built during code generation from + * Note that all ClassBTypes required in a non-optimized run are built during code generation from * the class symbols referenced by the ASTs, so they have a valid info. Therefore the backend * often invokes `info.get` (which asserts the info to exist) when reading data from the ClassBType. * diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala index 5f8f0e167c..cf29c8090b 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala @@ -355,7 +355,7 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes { // See comment in BTypes, when is a class marked static in the InnerClass table. val isStaticNestedClass = isOriginallyStaticOwner(innerClassSym.originalOwner) - // After lambdalift (which is where we are), the rawowoner field contains the enclosing class. + // After lambdalift (which is where we are), the rawowner field contains the enclosing class. val enclosingClass = { // (1) Example java source: class C { static class D { } } // The Scala compiler creates a class and a module symbol for C. Because D is a static diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala index 16e8aee1dd..00b4b8b667 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala @@ -167,6 +167,11 @@ abstract class GenBCode extends BCodeSyncAndTry { ) } + // shim for SBT, see https://github.com/sbt/sbt/issues/2076 + // TODO put this closer to classfile writing once we have closure elimination + // TODO create a nicer public API to find out the correspondence between sourcefile and ultimate classfiles + currentUnit.icode += new icodes.IClass(cd.symbol) + // -------------- mirror class, if needed -------------- val mirrorC = if (isTopLevelModuleClass(claszSymbol)) { diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index 3d688efae1..bd438f0e75 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -20,7 +20,7 @@ abstract class Reporter extends scala.reflect.internal.Reporter { /** Informational messages. If `!force`, they may be suppressed. */ final def info(pos: Position, msg: String, force: Boolean): Unit = info0(pos, msg, INFO, force) - /** For sending a message which should not be labeled as a warning/error, + /** For sending a message which should not be labelled as a warning/error, * but also shouldn't require -verbose to be visible. */ def echo(msg: String): Unit = info(NoPosition, msg, force = true) diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala index 9e9372f709..8beb1837ad 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala @@ -40,7 +40,7 @@ trait MatchWarnings { } } - // Issue better warnings than "unreachable code" when people mis-use + // Issue better warnings than "unreachable code" when people misuse // variable patterns thinking they bind to existing identifiers. // // Possible TODO: more deeply nested variable patterns, like 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() |