summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.sbt7
-rw-r--r--spec/04-basic-declarations-and-definitions.md30
-rw-r--r--spec/05-classes-and-objects.md1
-rw-r--r--src/build/genprod.scala13
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala22
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala34
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala20
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala58
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala2
-rw-r--r--src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
-rw-r--r--src/library/scala/Function0.scala8
-rw-r--r--src/library/scala/Function1.scala7
-rw-r--r--src/library/scala/Function2.scala6
-rw-r--r--src/library/scala/collection/immutable/List.scala2
-rw-r--r--src/library/scala/collection/immutable/NumericRange.scala8
-rw-r--r--src/library/scala/collection/immutable/Stream.scala6
-rw-r--r--src/library/scala/collection/immutable/Vector.scala17
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala2
-rw-r--r--src/library/scala/math/BigDecimal.scala4
-rw-r--r--src/library/scala/math/Numeric.scala6
-rw-r--r--src/library/scala/util/Try.scala2
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationCheckers.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala2
-rw-r--r--src/reflect/scala/reflect/runtime/JavaMirrors.scala1
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/Settings.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala1
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/Entity.scala6
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala14
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala2
-rw-r--r--test/files/jvm/bytecode-test-example/Test.scala2
-rw-r--r--test/files/jvm/t7006/Foo_1.scala2
-rw-r--r--test/files/neg/names-defaults-neg.check4
-rw-r--r--test/files/neg/names-defaults-neg.scala4
-rw-r--r--test/files/neg/t2866.check2
-rw-r--r--test/files/neg/t2866.scala2
-rw-r--r--test/files/pos/t6575b.scala2
-rw-r--r--test/files/pos/t6648.scala2
-rw-r--r--test/files/pos/t9356/Foo_2.scala6
-rw-r--r--test/files/pos/t9356/MyAnnotation.java12
-rw-r--r--test/files/pos/t9356/Test_3.scala3
-rw-r--r--test/files/run/kmpSliceSearch.flags1
-rw-r--r--test/files/run/range.scala18
-rw-r--r--test/files/run/t2106.check7
-rw-r--r--test/files/run/t2106.flags2
-rw-r--r--test/files/run/t6502.scala2
-rw-r--r--test/files/run/toolbox-varargs/Test.scala13
-rw-r--r--test/files/run/toolbox-varargs/Varargs.java8
-rw-r--r--test/junit/scala/collection/immutable/RangeConsistencyTest.scala11
-rw-r--r--test/junit/scala/math/BigDecimalTest.scala32
-rw-r--r--test/junit/scala/math/NumericTest.scala28
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala16
-rw-r--r--test/pending/pos/t1786.scala2
-rw-r--r--test/pending/run/idempotency-partial-functions.scala2
-rw-r--r--test/scaladoc/resources/implicits-base-res.scala2
-rw-r--r--test/scaladoc/run/implicits-base.scala2
-rw-r--r--test/scaladoc/scalacheck/HtmlFactoryTest.scala2
59 files changed, 344 insertions, 142 deletions
diff --git a/build.sbt b/build.sbt
index 76d66481d0..1e3bef2541 100644
--- a/build.sbt
+++ b/build.sbt
@@ -193,7 +193,12 @@ lazy val interactive = configureAsSubproject(project)
// TODO: SI-9339 embed shaded copy of jline & its interface (see #4563)
lazy val repl = configureAsSubproject(project)
- .settings(libraryDependencies += jlineDep)
+ .settings(
+ libraryDependencies += jlineDep,
+ connectInput in run := true,
+ outputStrategy in run := Some(StdoutOutput),
+ run <<= (run in Compile).partialInput(" -usejavacp") // Automatically add this so that `repl/run` works without additional arguments.
+ )
.settings(disableDocsAndPublishingTasks: _*)
.dependsOn(compiler)
diff --git a/spec/04-basic-declarations-and-definitions.md b/spec/04-basic-declarations-and-definitions.md
index 7fb5427d36..8437d2ea71 100644
--- a/spec/04-basic-declarations-and-definitions.md
+++ b/spec/04-basic-declarations-and-definitions.md
@@ -298,7 +298,7 @@ the sequence of variable definitions
```ebnf
Dcl ::= ‘type’ {nl} TypeDcl
TypeDcl ::= id [TypeParamClause] [‘>:’ Type] [‘<:’ Type]
-Def ::= type {nl} TypeDef
+Def ::= ‘type’ {nl} TypeDef
TypeDef ::= id [TypeParamClause] ‘=’ Type
```
@@ -620,7 +620,11 @@ well as the function body, if it is present.
A value parameter clause $\mathit{ps}$ consists of zero or more formal
parameter bindings such as `$x$: $T$` or `$x: T = e$`, which bind value
-parameters and associate them with their types. Each value parameter
+parameters and associate them with their types.
+
+### Default Arguments
+
+Each value parameter
declaration may optionally define a default argument. The default argument
expression $e$ is type-checked with an expected type $T'$ obtained
by replacing all occurences of the function's type parameters in $T$ by
@@ -632,13 +636,7 @@ expression. Here, $n$ denotes the parameter's position in the method
declaration. These methods are parametrized by the type parameter clause
`[$\mathit{tps}\,$]` and all value parameter clauses
`($\mathit{ps}_1$)$\ldots$($\mathit{ps}_{i-1}$)` preceding $p_{i,j}$.
-The `$f\$$default$\$$n` methods are inaccessible for
-user programs.
-
-The scope of a formal value parameter name $x$ comprises all subsequent
-parameter clauses, as well as the method return type and the function body, if
-they are given. Both type parameter names and value parameter names must
-be pairwise distinct.
+The `$f\$$default$\$$n` methods are inaccessible for user programs.
###### Example
In the method
@@ -657,6 +655,20 @@ def compare$\$$default$\$$1[T]: Int = 0
def compare$\$$default$\$$2[T](a: T): T = a
```
+The scope of a formal value parameter name $x$ comprises all subsequent
+parameter clauses, as well as the method return type and the function body, if
+they are given. Both type parameter names and value parameter names must
+be pairwise distinct.
+
+A default value which depends on earlier parameters uses the actual arguments
+if they are provided, not the default arguments.
+
+```scala
+def f(a: Int = 0)(b: Int = a + 1) = b // OK
+// def f(a: Int = 0, b: Int = a + 1) // "error: not found: value a"
+f(10)() // returns 11 (not 1)
+```
+
### By-Name Parameters
```ebnf
diff --git a/spec/05-classes-and-objects.md b/spec/05-classes-and-objects.md
index 28abe6c3bc..8be792d3cb 100644
--- a/spec/05-classes-and-objects.md
+++ b/spec/05-classes-and-objects.md
@@ -395,6 +395,7 @@ class C extends A with B { type T <: C }
Let $C$ be a class type. The _inheritance closure_ of $C$ is the
smallest set $\mathscr{S}$ of types such that
+- $C$ is in $\mathscr{S}$.
- If $T$ is in $\mathscr{S}$, then every type $T'$ which forms syntactically
a part of $T$ is also in $\mathscr{S}$.
- If $T$ is a class type in $\mathscr{S}$, then all [parents](#templates)
diff --git a/src/build/genprod.scala b/src/build/genprod.scala
index ed436fe2e4..b470348e8c 100644
--- a/src/build/genprod.scala
+++ b/src/build/genprod.scala
@@ -123,7 +123,10 @@ object FunctionOne extends Function(1) {
* def apply(x: Int): Int = x + 1
* }
* assert(succ(0) == anonfun1(0))
- * """)
+ * """) + """
+ *
+ * Note that the difference between `Function1` and [[scala.PartialFunction]]
+ * is that the latter can specify inputs which it will not handle."""
override def moreMethods = """
/** Composes two instances of Function1 in a new Function1, with this function applied last.
@@ -178,13 +181,7 @@ class Function(val i: Int) extends Group("Function") with Arity {
*
* {{{
* object Main extends App {%s}
- * }}}
- *
- * Note that `Function1` does not define a total function, as might
- * be suggested by the existence of [[scala.PartialFunction]]. The only
- * distinction between `Function1` and `PartialFunction` is that the
- * latter can specify inputs which it will not handle.
-"""
+ * }}}"""
def toStr() = "\"" + ("<function%d>" format i) + "\""
def apply() = {
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 4430a84f06..3469726455 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1675,23 +1675,25 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
def getFile(clazz: Symbol, suffix: String): File = getFile(clazz.sourceFile, clazz.fullName split '.', suffix)
private def writeICode() {
- val printer = new icodes.TextPrinter(null, icodes.linearizer)
- icodes.classes.values.foreach((cls) => {
- val moduleSfx = if (cls.symbol.hasModuleFlag) "$" else ""
- val phaseSfx = if (settings.debug) phase else "" // only for debugging, appending the full phasename breaks windows build
- val file = getFile(cls.symbol, s"$moduleSfx$phaseSfx.icode")
+ val printer = new icodes.TextPrinter(writer = null, icodes.linearizer)
+ icodes.classes.values foreach { cls =>
+ val file = {
+ val module = if (cls.symbol.hasModuleFlag) "$" else ""
+ val faze = if (settings.debug) phase.name else f"${phase.id}%02d" // avoid breaking windows build with long filename
+ getFile(cls.symbol, s"$module-$faze.icode")
+ }
try {
val stream = new FileOutputStream(file)
printer.setWriter(new PrintWriter(stream, true))
printer.printClass(cls)
- informProgress("wrote " + file)
+ informProgress(s"wrote $file")
} catch {
- case ex: IOException =>
- if (settings.debug) ex.printStackTrace()
- globalError("could not write file " + file)
+ case e: IOException =>
+ if (settings.debug) e.printStackTrace()
+ globalError(s"could not write file $file")
}
- })
+ }
}
def createJavadoc = false
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala
index 1b9fd5e298..fffb9286b8 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala
@@ -213,6 +213,35 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
assert(!primitiveTypeMap.contains(sym) || isCompilingPrimitive, sym)
}
+ /**
+ * Reconstruct the classfile flags from a Java defined class symbol.
+ *
+ * The implementation of this method is slightly different that [[javaFlags]]. The javaFlags
+ * method is primarily used to map Scala symbol flags to sensible classfile flags that are used
+ * in the generated classfiles. For example, all classes emitted by the Scala compiler have
+ * ACC_PUBLIC.
+ *
+ * When building a [[ClassBType]] from a Java class symbol, the flags in the type's `info` have
+ * to correspond exactly to the flags in the classfile. For example, if the class is package
+ * protected (i.e., it doesn't have the ACC_PUBLIC flag), this needs to be reflected in the
+ * ClassBType. For example, the inliner needs the correct flags for access checks.
+ *
+ * Class flags are listed here:
+ * https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1-200-E.1
+ */
+ private def javaClassfileFlags(classSym: Symbol): Int = {
+ assert(classSym.isJava, s"Expected Java class symbol, got ${classSym.fullName}")
+ import asm.Opcodes._
+ GenBCode.mkFlags(
+ if (classSym.isPublic) ACC_PUBLIC else 0,
+ if (classSym.isFinal) ACC_FINAL else 0,
+ if (classSym.isInterface) ACC_INTERFACE else ACC_SUPER, // see the link above. javac does the same: ACC_SUPER for all classes, but not interfaces.
+ if (classSym.hasAbstractFlag) ACC_ABSTRACT else 0,
+ if (classSym.isArtifact) ACC_SYNTHETIC else 0,
+ if (classSym.hasEnumFlag) ACC_ENUM else 0
+ )
+ }
+
private def setClassInfo(classSym: Symbol, classBType: ClassBType): ClassBType = {
val superClassSym = if (classSym.isImplClass) ObjectClass else classSym.superClass
assert(
@@ -230,7 +259,10 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
val interfaces = implementedInterfaces(classSym).map(classBTypeFromSymbol)
- val flags = javaFlags(classSym)
+ val flags = {
+ if (classSym.isJava) javaClassfileFlags(classSym) // see comment on javaClassfileFlags
+ else javaFlags(classSym)
+ }
/* The InnerClass table of a class C must contain all nested classes of C, even if they are only
* declared but not otherwise referenced in C (from the bytecode or a method / field signature).
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index f866c0d038..76af40b330 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -617,18 +617,16 @@ abstract class GenASM extends SubComponent with BytecodeWriters { self =>
val internalName = cachedJN.toString()
val trackedSym = jsymbol(sym)
reverseJavaName.get(internalName) match {
- case Some(oldsym) if oldsym.exists && trackedSym.exists =>
- assert(
- // In contrast, neither NothingClass nor NullClass show up bytecode-level.
- (oldsym == trackedSym) || (oldsym == RuntimeNothingClass) || (oldsym == RuntimeNullClass) || (oldsym.isModuleClass && (oldsym.sourceModule == trackedSym.sourceModule)),
- s"""|Different class symbols have the same bytecode-level internal name:
- | name: $internalName
- | oldsym: ${oldsym.fullNameString}
- | tracked: ${trackedSym.fullNameString}
- """.stripMargin
- )
- case _ =>
+ case None =>
reverseJavaName.put(internalName, trackedSym)
+ case Some(oldsym) =>
+ // TODO: `duplicateOk` seems pretty ad-hoc (a more aggressive version caused SI-9356 because it called oldSym.exists, which failed in the unpickler; see also SI-5031)
+ def duplicateOk = oldsym == NoSymbol || trackedSym == NoSymbol || (syntheticCoreClasses contains oldsym) || (oldsym.isModuleClass && (oldsym.sourceModule == trackedSym.sourceModule))
+ if (oldsym != trackedSym && !duplicateOk)
+ devWarning(s"""|Different class symbols have the same bytecode-level internal name:
+ | name: $internalName
+ | oldsym: ${oldsym.fullNameString}
+ | tracked: ${trackedSym.fullNameString}""".stripMargin)
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
index 814c78b69c..b4f091b37f 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
@@ -562,38 +562,62 @@ class Inliner[BT <: BTypes](val btypes: BT) {
* @param memberDeclClass The class in which the member is declared (A)
* @param memberRefClass The class used in the member reference (B)
*
+ * (B0) JVMS 5.4.3.2 / 5.4.3.3: when resolving a member of class C in D, the class C is resolved
+ * first. According to 5.4.3.1, this requires C to be accessible in D.
+ *
* JVMS 5.4.4 summary: A field or method R is accessible to a class D (destinationClass) iff
* (B1) R is public
* (B2) R is protected, declared in C (memberDeclClass) and D is a subclass of C.
* If R is not static, R must contain a symbolic reference to a class T (memberRefClass),
* such that T is either a subclass of D, a superclass of D, or D itself.
+ * Also (P) needs to be satisfied.
* (B3) R is either protected or has default access and declared by a class in the same
* run-time package as D.
+ * If R is protected, also (P) needs to be satisfied.
* (B4) R is private and is declared in D.
+ *
+ * (P) When accessing a protected instance member, the target object on the stack (the receiver)
+ * has to be a subtype of D (destinationClass). This is enforced by classfile verification
+ * (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.10.1.8).
+ *
+ * TODO: we cannot currently implement (P) because we don't have the necessary information
+ * available. Once we have a type propagation analysis implemented, we can extract the receiver
+ * type from there (https://github.com/scala-opt/scala/issues/13).
*/
def memberIsAccessible(memberFlags: Int, memberDeclClass: ClassBType, memberRefClass: ClassBType): Either[OptimizerWarning, Boolean] = {
// TODO: B3 requires "same run-time package", which seems to be package + classloader (JMVS 5.3.). is the below ok?
def samePackageAsDestination = memberDeclClass.packageInternalName == destinationClass.packageInternalName
-
- val key = (ACC_PUBLIC | ACC_PROTECTED | ACC_PRIVATE) & memberFlags
- key match {
- case ACC_PUBLIC => // B1
- Right(true)
-
- case ACC_PROTECTED => // B2
- tryEither {
- val condB2 = destinationClass.isSubtypeOf(memberDeclClass).orThrow && {
- val isStatic = (ACC_STATIC & memberFlags) != 0
- isStatic || memberRefClass.isSubtypeOf(destinationClass).orThrow || destinationClass.isSubtypeOf(memberRefClass).orThrow
+ def targetObjectConformsToDestinationClass = false // needs type propagation analysis, see above
+
+ def memberIsAccessibleImpl = {
+ val key = (ACC_PUBLIC | ACC_PROTECTED | ACC_PRIVATE) & memberFlags
+ key match {
+ case ACC_PUBLIC => // B1
+ Right(true)
+
+ case ACC_PROTECTED => // B2
+ val isStatic = (ACC_STATIC & memberFlags) != 0
+ tryEither {
+ val condB2 = destinationClass.isSubtypeOf(memberDeclClass).orThrow && {
+ isStatic || memberRefClass.isSubtypeOf(destinationClass).orThrow || destinationClass.isSubtypeOf(memberRefClass).orThrow
+ }
+ Right(
+ (condB2 || samePackageAsDestination /* B3 (protected) */) &&
+ (isStatic || targetObjectConformsToDestinationClass) // (P)
+ )
}
- Right(condB2 || samePackageAsDestination) // B3 (protected)
- }
- case 0 => // B3 (default access)
- Right(samePackageAsDestination)
+ case 0 => // B3 (default access)
+ Right(samePackageAsDestination)
+
+ case ACC_PRIVATE => // B4
+ Right(memberDeclClass == destinationClass)
+ }
+ }
- case ACC_PRIVATE => // B4
- Right(memberDeclClass == destinationClass)
+ classIsAccessible(memberDeclClass) match { // B0
+ case Right(true) => memberIsAccessibleImpl
+ case r => r
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index 8f6fc65706..8cd2a14066 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -773,7 +773,7 @@ abstract class Inliners extends SubComponent {
staleOut += block
- tfa.remainingCALLs.remove(instr) // this bookkpeeping is done here and not in MTFAGrowable.reinit due to (1st) convenience and (2nd) necessity.
+ tfa.remainingCALLs.remove(instr) // this bookkeeping is done here and not in MTFAGrowable.reinit due to (1st) convenience and (2nd) necessity.
tfa.isOnWatchlist.remove(instr) // ditto
tfa.warnIfInlineFails.remove(instr)
diff --git a/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala b/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
index 84e21a3ccd..85c7c3c843 100644
--- a/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
+++ b/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
@@ -61,7 +61,7 @@ object ZipAndJarFlatClassPathFactory extends ZipAndJarFileLookupFactory {
}
/**
- * This type of classpath is closly related to the support for JSR-223.
+ * This type of classpath is closely related to the support for JSR-223.
* Its usage can be observed e.g. when running:
* jrunscript -classpath scala-compiler.jar;scala-reflect.jar;scala-library.jar -l scala
* with a particularly prepared scala-library.jar. It should have all classes listed in the manifest like e.g. this entry:
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index a22428075c..4f5589fd7c 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -373,7 +373,7 @@ abstract class SymbolLoaders {
protected def doComplete(root: Symbol) { root.sourceModule.initialize }
}
- /** used from classfile parser to avoid cyclies */
+ /** used from classfile parser to avoid cycles */
var parentsLevel = 0
var pendingLoadActions: List[() => Unit] = Nil
}
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
index 6302e34ac9..451b72d498 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
@@ -248,7 +248,7 @@ trait MatchTranslation {
if (caseDefs forall treeInfo.isCatchCase) caseDefs
else {
val swatches = { // switch-catches
- // SI-7459 must duplicate here as we haven't commited to switch emission, and just figuring out
+ // SI-7459 must duplicate here as we haven't committed to switch emission, and just figuring out
// if we can ends up mutating `caseDefs` down in the use of `substituteSymbols` in
// `TypedSubstitution#Substitution`. That is called indirectly by `emitTypeSwitch`.
val bindersAndCases = caseDefs.map(_.duplicate) map { caseDef =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 27a574a449..b5129af9ec 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4443,7 +4443,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
def onError(typeErrors: Seq[AbsTypeError], warnings: Seq[(Position, String)]): Tree = {
if (Statistics.canEnable) Statistics.stopTimer(failedApplyNanos, start)
- // If the problem is with raw types, copnvert to existentials and try again.
+ // If the problem is with raw types, convert to existentials and try again.
// See #4712 for a case where this situation arises,
if ((fun.symbol ne null) && fun.symbol.isJavaDefined) {
val newtpe = rawToExistential(fun.tpe)
@@ -4988,7 +4988,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
TypeTreeWithDeferredRefCheck(){ () =>
// wrap the tree and include the bounds check -- refchecks will perform this check (that the beta reduction was indeed allowed) and unwrap
// we can't simply use original in refchecks because it does not contains types
- // (and the only typed trees we have have been mangled so they're not quite the original tree anymore)
+ // (and the only typed trees we have been mangled so they're not quite the original tree anymore)
checkBounds(result, tpt1.tpe.prefix, tpt1.symbol.owner, tpt1.symbol.typeParams, argtypes, "")
result // you only get to see the wrapped tree after running this check :-p
} setType (result.tpe) setPos(result.pos)
diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala
index e13aaad7bc..15d0f14938 100644
--- a/src/library/scala/Function0.scala
+++ b/src/library/scala/Function0.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
// GENERATED CODE: DO NOT EDIT.
-// genprod generated these sources at: Sun Sep 15 20:42:00 CEST 2013
+// genprod generated these sources at: Mon Jun 08 18:05:40 CEST 2015
package scala
@@ -26,12 +26,6 @@ package scala
* assert(javaVersion() == anonfun0())
* }
* }}}
- *
- * Note that `Function1` does not define a total function, as might
- * be suggested by the existence of [[scala.PartialFunction]]. The only
- * distinction between `Function1` and `PartialFunction` is that the
- * latter can specify inputs which it will not handle.
-
*/
trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef { self =>
/** Apply the body of this function to the arguments.
diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala
index 620dcc19aa..572901c6f3 100644
--- a/src/library/scala/Function1.scala
+++ b/src/library/scala/Function1.scala
@@ -25,11 +25,8 @@ package scala
* }
* }}}
*
- * Note that `Function1` does not define a total function, as might
- * be suggested by the existence of [[scala.PartialFunction]]. The only
- * distinction between `Function1` and `PartialFunction` is that the
- * latter can specify inputs which it will not handle.
-
+ * Note that the difference between `Function1` and [[scala.PartialFunction]]
+ * is that the latter can specify inputs which it will not handle.
*/
@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.")
trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) +R] extends AnyRef { self =>
diff --git a/src/library/scala/Function2.scala b/src/library/scala/Function2.scala
index 5690adb56a..e2c094ea40 100644
--- a/src/library/scala/Function2.scala
+++ b/src/library/scala/Function2.scala
@@ -25,12 +25,6 @@ package scala
* assert(max(0, 1) == anonfun2(0, 1))
* }
* }}}
- *
- * Note that `Function1` does not define a total function, as might
- * be suggested by the existence of [[scala.PartialFunction]]. The only
- * distinction between `Function1` and `PartialFunction` is that the
- * latter can specify inputs which it will not handle.
-
*/
trait Function2[@specialized(scala.Int, scala.Long, scala.Double) -T1, @specialized(scala.Int, scala.Long, scala.Double) -T2, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) +R] extends AnyRef { self =>
/** Apply the body of this function to the arguments.
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 254f14f13c..82e38d3549 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -462,6 +462,7 @@ object List extends SeqFactory[List] {
private class SerializationProxy[A](@transient private var orig: List[A]) extends Serializable {
private def writeObject(out: ObjectOutputStream) {
+ out.defaultWriteObject()
var xs: List[A] = orig
while (!xs.isEmpty) {
out.writeObject(xs.head)
@@ -473,6 +474,7 @@ object List extends SeqFactory[List] {
// Java serialization calls this before readResolve during de-serialization.
// Read the whole list and store it in `orig`.
private def readObject(in: ObjectInputStream) {
+ in.defaultReadObject()
val builder = List.newBuilder[A]
while (true) in.readObject match {
case ListSerializeEnd =>
diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala
index f1ac161e9a..28e56a6d87 100644
--- a/src/library/scala/collection/immutable/NumericRange.scala
+++ b/src/library/scala/collection/immutable/NumericRange.scala
@@ -12,6 +12,9 @@ package immutable
import mutable.{ Builder, ListBuffer }
+// TODO: Now the specialization exists there is no clear reason to have
+// separate classes for Range/NumericRange. Investigate and consolidate.
+
/** `NumericRange` is a more generic version of the
* `Range` class which works with arbitrary types.
* It must be supplied with an `Integral` implementation of the
@@ -28,9 +31,6 @@ import mutable.{ Builder, ListBuffer }
* assert(r1 sameElements r2.map(_ - veryBig))
* }}}
*
- * TODO: Now the specialization exists there is no clear reason to have
- * separate classes for Range/NumericRange. Investigate and consolidate.
- *
* @author Paul Phillips
* @version 2.8
* @define Coll `NumericRange`
@@ -266,7 +266,7 @@ object NumericRange {
// Numbers may be big.
val one = num.one
val limit = num.fromInt(Int.MaxValue)
- def check(t: T): T =
+ def check(t: T): T =
if (num.gt(t, limit)) throw new IllegalArgumentException("More than Int.MaxValue elements.")
else t
// If the range crosses zero, it might overflow when subtracted
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index cf7b7e272a..7edd36dc22 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -1180,7 +1180,13 @@ object Stream extends SeqFactory[Stream] {
* to streams.
*/
class ConsWrapper[A](tl: => Stream[A]) {
+ /** Construct a stream consisting of a given first element followed by elements
+ * from a lazily evaluated Stream.
+ */
def #::(hd: A): Stream[A] = cons(hd, tl)
+ /** Construct a stream consisting of the concatenation of the given stream and
+ * a lazily evaluated Stream.
+ */
def #:::(prefix: Stream[A]): Stream[A] = prefix append tl
}
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala
index 47a623a616..46d5d0c69c 100644
--- a/src/library/scala/collection/immutable/Vector.scala
+++ b/src/library/scala/collection/immutable/Vector.scala
@@ -132,19 +132,25 @@ override def companion: GenericCompanion[Vector] = Vector
throw new IndexOutOfBoundsException(index.toString)
}
-
+ // If we have a default builder, there are faster ways to perform some operations
+ @inline private[this] def isDefaultCBF[A, B, That](bf: CanBuildFrom[Vector[A], B, That]): Boolean =
+ (bf eq IndexedSeq.ReusableCBF) || (bf eq collection.immutable.Seq.ReusableCBF) || (bf eq collection.Seq.ReusableCBF)
+
// SeqLike api
override def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That =
- if (bf eq IndexedSeq.ReusableCBF) updateAt(index, elem).asInstanceOf[That] // just ignore bf
+ if (isDefaultCBF[A, B, That](bf))
+ updateAt(index, elem).asInstanceOf[That] // ignore bf--it will just give a Vector, and slowly
else super.updated(index, elem)(bf)
override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That =
- if (bf eq IndexedSeq.ReusableCBF) appendFront(elem).asInstanceOf[That] // just ignore bf
+ if (isDefaultCBF[A, B, That](bf))
+ appendFront(elem).asInstanceOf[That] // ignore bf--it will just give a Vector, and slowly
else super.+:(elem)(bf)
override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That =
- if (bf eq IndexedSeq.ReusableCBF) appendBack(elem).asInstanceOf[That] // just ignore bf
+ if (isDefaultCBF(bf))
+ appendBack(elem).asInstanceOf[That] // ignore bf--it will just give a Vector, and slowly
else super.:+(elem)(bf)
override def take(n: Int): Vector[A] = {
@@ -211,7 +217,8 @@ override def companion: GenericCompanion[Vector] = Vector
// concat (suboptimal but avoids worst performance gotchas)
override def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Vector[A], B, That]): That = {
- if (bf eq IndexedSeq.ReusableCBF) {
+ if (isDefaultCBF(bf)) {
+ // We are sure we will create a Vector, so let's do it efficiently
import Vector.{Log2ConcatFaster, TinyAppendFaster}
if (that.isEmpty) this.asInstanceOf[That]
else {
diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala
index 8faaf97741..f9bab40a1e 100644
--- a/src/library/scala/collection/mutable/ListBuffer.scala
+++ b/src/library/scala/collection/mutable/ListBuffer.scala
@@ -15,7 +15,7 @@ import immutable.{List, Nil, ::}
import java.io._
import scala.annotation.migration
-/** A `Buffer` implementation back up by a list. It provides constant time
+/** A `Buffer` implementation backed by a list. It provides constant time
* prepend and append. Most other operations are linear.
*
* @author Matthias Zenger
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index d6e2963ad8..6bb35606a6 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -49,7 +49,7 @@ object BigDecimal {
/** Constructs a `BigDecimal` using the decimal text representation of `Double` value `d`, rounding if necessary. */
def decimal(d: Double, mc: MathContext): BigDecimal =
- new BigDecimal(new BigDec(java.lang.Double.toString(d), mc))
+ new BigDecimal(new BigDec(java.lang.Double.toString(d), mc), mc)
/** Constructs a `BigDecimal` using the decimal text representation of `Double` value `d`. */
def decimal(d: Double): BigDecimal = decimal(d, defaultMathContext)
@@ -59,7 +59,7 @@ object BigDecimal {
* `0.1 != 0.1f`.
*/
def decimal(f: Float, mc: MathContext): BigDecimal =
- new BigDecimal(new BigDec(java.lang.Float.toString(f), mc))
+ new BigDecimal(new BigDec(java.lang.Float.toString(f), mc), mc)
/** Constructs a `BigDecimal` using the decimal text representation of `Float` value `f`.
* Note that `BigDecimal.decimal(0.1f) != 0.1f` since equality agrees with the `Double` representation, and
diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala
index eafbf96993..9245798c17 100644
--- a/src/library/scala/math/Numeric.scala
+++ b/src/library/scala/math/Numeric.scala
@@ -134,7 +134,7 @@ object Numeric {
def div(x: Float, y: Float): Float = x / y
}
trait FloatAsIfIntegral extends FloatIsConflicted with Integral[Float] {
- def quot(x: Float, y: Float): Float = (BigDecimal(x) / BigDecimal(y)).floatValue
+ def quot(x: Float, y: Float): Float = (BigDecimal(x) quot BigDecimal(y)).floatValue
def rem(x: Float, y: Float): Float = (BigDecimal(x) remainder BigDecimal(y)).floatValue
}
implicit object FloatIsFractional extends FloatIsFractional with Ordering.FloatOrdering
@@ -158,7 +158,7 @@ object Numeric {
def div(x: Double, y: Double): Double = x / y
}
trait DoubleAsIfIntegral extends DoubleIsConflicted with Integral[Double] {
- def quot(x: Double, y: Double): Double = (BigDecimal(x) / BigDecimal(y)).doubleValue
+ def quot(x: Double, y: Double): Double = (BigDecimal(x) quot BigDecimal(y)).doubleValue
def rem(x: Double, y: Double): Double = (BigDecimal(x) remainder BigDecimal(y)).doubleValue
}
@@ -178,7 +178,7 @@ object Numeric {
def div(x: BigDecimal, y: BigDecimal): BigDecimal = x / y
}
trait BigDecimalAsIfIntegral extends BigDecimalIsConflicted with Integral[BigDecimal] {
- def quot(x: BigDecimal, y: BigDecimal): BigDecimal = x / y
+ def quot(x: BigDecimal, y: BigDecimal): BigDecimal = x quot y
def rem(x: BigDecimal, y: BigDecimal): BigDecimal = x remainder y
}
diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala
index 0a6a7972c2..b0eae74043 100644
--- a/src/library/scala/util/Try.scala
+++ b/src/library/scala/util/Try.scala
@@ -48,7 +48,7 @@ import scala.language.implicitConversions
* catching exceptions along the way. The `flatMap` and `map` combinators in the above example each essentially
* pass off either their successfully completed value, wrapped in the `Success` type for it to be further operated
* upon by the next combinator in the chain, or the exception wrapped in the `Failure` type usually to be simply
- * passed on down the chain. Combinators such as `rescue` and `recover` are designed to provide some type of
+ * passed on down the chain. Combinators such as `recover` and `recoverWith` are designed to provide some type of
* default behavior in the case of failure.
*
* ''Note'': only non-fatal exceptions are caught by the combinators on `Try` (see [[scala.util.control.NonFatal]]).
diff --git a/src/reflect/scala/reflect/internal/AnnotationCheckers.scala b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala
index 74310e1c34..1ba014d19d 100644
--- a/src/reflect/scala/reflect/internal/AnnotationCheckers.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala
@@ -60,7 +60,7 @@ trait AnnotationCheckers {
* mode (see method adapt in trait Typers).
*
* An implementation cannot rely on canAdaptAnnotations being called before. If the implementing
- * class cannot do the adaptiong, it should return the tree unchanged.
+ * class cannot do the adapting, it should return the tree unchanged.
*/
@deprecated("Create an AnalyzerPlugin and use adaptAnnotations", "2.10.1")
def adaptAnnotations(tree: Tree, mode: Mode, pt: Type): Tree = tree
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index abe966920b..285d59c5e2 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -987,7 +987,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
|| isLocalToBlock
)
)
- /** Is this symbol effectively final or a concrete term member of sealed class whose childred do not override it */
+ /** Is this symbol effectively final or a concrete term member of sealed class whose children do not override it */
final def isEffectivelyFinalOrNotOverridden: Boolean = isEffectivelyFinal || (isTerm && !isDeferred && isNotOverridden)
/** Is this symbol owned by a package? */
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
index ce60ade9f5..8c32a92ecd 100644
--- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala
+++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
@@ -1184,6 +1184,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive
constr setInfo GenPolyType(tparams, MethodType(clazz.newSyntheticValueParams(paramtpes), clazz.tpe))
propagatePackageBoundary(jconstr.javaFlags, constr)
copyAnnotations(constr, jconstr)
+ if (jconstr.javaFlags.isVarargs) constr modifyInfo arrayToRepeated
markAllCompleted(constr)
constr
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/Settings.scala b/src/scaladoc/scala/tools/nsc/doc/Settings.scala
index 44683f1755..067b2b2c29 100644
--- a/src/scaladoc/scala/tools/nsc/doc/Settings.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/Settings.scala
@@ -143,7 +143,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
"dot" // by default, just pick up the system-wide dot
)
- /** The maxium nuber of normal classes to show in the diagram */
+ /** The maximum number of normal classes to show in the diagram */
val docDiagramsMaxNormalClasses = IntSetting(
"-diagrams-max-classes",
"The maximum number of superclasses or subclasses to show in a diagram",
@@ -152,7 +152,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
_ => None
)
- /** The maxium nuber of implcit classes to show in the diagram */
+ /** The maximum number of implicit classes to show in the diagram */
val docDiagramsMaxImplicitClasses = IntSetting(
"-diagrams-max-implicits",
"The maximum number of implicitly converted classes to show in a diagram",
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
index c384ed7034..81036b4908 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
@@ -177,7 +177,6 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp
<li class="hideall out"><span>Hide All</span></li>
<li class="showall in"><span>Show all</span></li>
</ol>
- <a href="http://docs.scala-lang.org/overviews/scaladoc/usage.html#members" target="_blank">Learn more about member selection</a>
</div>
}
{
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala b/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala
index 7fe8903c76..90de51d763 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala
@@ -298,7 +298,7 @@ trait DocTemplateEntity extends MemberTemplateEntity {
/** The shadowing information for the implicitly added members */
def implicitsShadowing: Map[MemberEntity, ImplicitMemberShadowing]
- /** Classes that can be implcitly converted to this class */
+ /** Classes that can be implicitly converted to this class */
def incomingImplicitlyConvertedClasses: List[(DocTemplateEntity, ImplicitConversion)]
/** Classes to which this class can be implicitly converted to
@@ -484,10 +484,10 @@ trait ImplicitConversion {
/** The entity for the method that performed the conversion, if it's documented (or just its name, otherwise) */
def convertorMethod: Either[MemberEntity, String]
- /** A short name of the convertion */
+ /** A short name of the conversion */
def conversionShortName: String
- /** A qualified name uniquely identifying the convertion (currently: the conversion method's qualified name) */
+ /** A qualified name uniquely identifying the conversion (currently: the conversion method's qualified name) */
def conversionQualifiedName: String
/** The entity that performed the conversion */
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
index f984b4579f..db39d059d7 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -90,8 +90,12 @@ trait ModelFactoryImplicitSupport {
else {
val context: global.analyzer.Context = global.analyzer.rootContext(NoCompilationUnit)
- val results = global.analyzer.allViewsFrom(sym.tpe_*, context, sym.typeParams)
+ val results = global.analyzer.allViewsFrom(sym.tpe_*, context, sym.typeParams) ++
+ global.analyzer.allViewsFrom(byNameType(sym.tpe_*), context, sym.typeParams)
var conversions = results.flatMap(result => makeImplicitConversion(sym, result._1, result._2, context, inTpl))
+ //debug(results.mkString("All views\n ", "\n ", "\n"))
+ //debug(conversions.mkString("Conversions\n ", "\n ", "\n"))
+
// also keep empty conversions, so they appear in diagrams
// conversions = conversions.filter(!_.members.isEmpty)
@@ -193,7 +197,7 @@ trait ModelFactoryImplicitSupport {
List(new ImplicitConversionImpl(sym, result.tree.symbol, toType, constraints, inTpl))
} catch {
case i: ImplicitNotFound =>
- //println(" Eliminating: " + toType)
+ //debug(s" Eliminating: $toType")
Nil
}
}
@@ -396,7 +400,7 @@ trait ModelFactoryImplicitSupport {
def isHiddenConversion = settings.hiddenImplicits(conversionQualifiedName)
- override def toString = "Implcit conversion from " + sym.tpe + " to " + toType + " done by " + convSym
+ override def toString = "Implicit conversion from " + sym.tpe + " to " + toType + " done by " + convSym
}
/* ========================= HELPER METHODS ========================== */
@@ -475,7 +479,7 @@ trait ModelFactoryImplicitSupport {
}
/**
- * Make implicits explicit - Not used curently
+ * Make implicits explicit - Not used currently
*/
// object implicitToExplicit extends TypeMap {
// def apply(tp: Type): Type = mapOver(tp) match {
@@ -557,7 +561,7 @@ trait ModelFactoryImplicitSupport {
*
* The trick here is that the resultType does not matter - the condition for removal it that paramss have the same
* structure (A => B => C may not override (A, B) => C) and that all the types involved are
- * of the implcit conversion's member are subtypes of the parent members' parameters */
+ * of the implicit conversion's member are subtypes of the parent members' parameters */
def isDistinguishableFrom(t1: Type, t2: Type): Boolean = {
// Vlad: I tried using matches but it's not exactly what we need:
// (p: AnyRef)AnyRef matches ((t: String)AnyRef returns false -- but we want that to be true
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
index 87d7ece8f2..093899231e 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
@@ -51,7 +51,7 @@ trait DiagramFactory extends DiagramDirectiveParser {
case p: (TemplateEntity, TypeEntity) if !classExcluded(p._1) => NormalNode(p._2, Some(p._1))()
}.reverse
- // incoming implcit conversions
+ // incoming implicit conversions
lazy val incomingImplicitNodes = tpl.incomingImplicitlyConvertedClasses.map {
case (incomingTpl, conv) =>
ImplicitNode(makeType(incomingTpl.sym.tpe, tpl), Some(incomingTpl))(implicitTooltip(from=incomingTpl, to=tpl, conv=conv))
diff --git a/test/files/jvm/bytecode-test-example/Test.scala b/test/files/jvm/bytecode-test-example/Test.scala
index d668059cb7..0da54d5bde 100644
--- a/test/files/jvm/bytecode-test-example/Test.scala
+++ b/test/files/jvm/bytecode-test-example/Test.scala
@@ -17,7 +17,7 @@ object Test extends BytecodeTest {
def countNullChecks(insnList: InsnList): Int = {
/** Is given instruction a null check?
* NOTE
- * This will detect direct null compparsion as in
+ * This will detect direct null comparison as in
* if (x == null) ...
* and not indirect as in
* val foo = null
diff --git a/test/files/jvm/t7006/Foo_1.scala b/test/files/jvm/t7006/Foo_1.scala
index 995619ce6b..3985557d9f 100644
--- a/test/files/jvm/t7006/Foo_1.scala
+++ b/test/files/jvm/t7006/Foo_1.scala
@@ -5,6 +5,6 @@ class Foo_1 {
} finally {
print("hello")
}
- while(true){} // ensure infinite loop doesn't break the algoirthm
+ while(true){} // ensure infinite loop doesn't break the algorithm
}
}
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index 2db24b6f32..a43bf66811 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -64,7 +64,7 @@ names-defaults-neg.scala:49: error: ambiguous reference to overloaded definition
both method g in object t7 of type (a: B)String
and method g in object t7 of type (a: C, b: Int*)String
match argument types (C)
- t7.g(new C()) // ambigous reference
+ t7.g(new C()) // ambiguous reference
^
names-defaults-neg.scala:53: error: parameter 'b' is already specified at parameter position 2
test5(a = 1, b = "dkjl", b = "dkj")
@@ -79,7 +79,7 @@ names-defaults-neg.scala:61: error: ambiguous reference to overloaded definition
both method f in object t8 of type (b: String, a: Int)String
and method f in object t8 of type (a: Int, b: Object)String
match argument types (a: Int,b: String) and expected result type Any
- println(t8.f(a = 0, b = "1")) // ambigous reference
+ println(t8.f(a = 0, b = "1")) // ambiguous reference
^
names-defaults-neg.scala:69: error: wrong number of arguments for pattern A1(x: Int,y: String)
A1() match { case A1(_) => () }
diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala
index 042f73708c..a97b590bf2 100644
--- a/test/files/neg/names-defaults-neg.scala
+++ b/test/files/neg/names-defaults-neg.scala
@@ -46,7 +46,7 @@ object Test extends App {
def g(a: C, b: Int*) = "third"
def g(a: B) = "fourth"
}
- t7.g(new C()) // ambigous reference
+ t7.g(new C()) // ambiguous reference
// vararg
def test5(a: Int, b: String*) = a
@@ -58,7 +58,7 @@ object Test extends App {
def f(a: Int, b: Object) = "first"
def f(b: String, a: Int) = "second"
}
- println(t8.f(a = 0, b = "1")) // ambigous reference
+ println(t8.f(a = 0, b = "1")) // ambiguous reference
// case class copy does not exist if there's a vararg
diff --git a/test/files/neg/t2866.check b/test/files/neg/t2866.check
index 340fb8da22..bc0da7e355 100644
--- a/test/files/neg/t2866.check
+++ b/test/files/neg/t2866.check
@@ -5,7 +5,7 @@ t2866.scala:42: error: ambiguous implicit values:
both value two of type Int
and value one in object A of type => Int
match expected type Int
- assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambigous in 2.7.6
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambiguous in 2.7.6
^
t2866.scala:50: error: ambiguous implicit values:
both value two of type Int
diff --git a/test/files/neg/t2866.scala b/test/files/neg/t2866.scala
index 55ebff9710..6be8bf9e89 100644
--- a/test/files/neg/t2866.scala
+++ b/test/files/neg/t2866.scala
@@ -39,7 +39,7 @@ object Test {
import A.one
assert(implicitly[Int] == 1)
implicit val two = 2
- assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambigous in 2.7.6
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambiguous in 2.7.6
}
locally {
diff --git a/test/files/pos/t6575b.scala b/test/files/pos/t6575b.scala
index d3e58b2a16..c89424287a 100644
--- a/test/files/pos/t6575b.scala
+++ b/test/files/pos/t6575b.scala
@@ -1,5 +1,5 @@
// inferred types were okay here as Function nodes aren't
-// translated into anoymous subclasses of AbstractFunctionN
+// translated into anonymous subclasses of AbstractFunctionN
// until after the typer.
//
// So this test is just confirmation.
diff --git a/test/files/pos/t6648.scala b/test/files/pos/t6648.scala
index 9593ebfee9..b8f24870cc 100644
--- a/test/files/pos/t6648.scala
+++ b/test/files/pos/t6648.scala
@@ -10,7 +10,7 @@ class Transformer {
}
object transformer1 extends Transformer {
- // Adding explicit type arguments, or making the impilcit view
+ // Adding explicit type arguments, or making the implicit view
// seqToNodeSeq explicit avoids the crash
NodeSeq.foo {
// These both avoid the crash:
diff --git a/test/files/pos/t9356/Foo_2.scala b/test/files/pos/t9356/Foo_2.scala
new file mode 100644
index 0000000000..ab7bb44d0e
--- /dev/null
+++ b/test/files/pos/t9356/Foo_2.scala
@@ -0,0 +1,6 @@
+class C
+
+trait Foo {
+ @annot.MyAnnotation(cls = classOf[C])
+ def function: Any = ???
+}
diff --git a/test/files/pos/t9356/MyAnnotation.java b/test/files/pos/t9356/MyAnnotation.java
new file mode 100644
index 0000000000..b6c00e7356
--- /dev/null
+++ b/test/files/pos/t9356/MyAnnotation.java
@@ -0,0 +1,12 @@
+package annot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface MyAnnotation {
+ Class<?> cls();
+}
diff --git a/test/files/pos/t9356/Test_3.scala b/test/files/pos/t9356/Test_3.scala
new file mode 100644
index 0000000000..fa1b76c9e1
--- /dev/null
+++ b/test/files/pos/t9356/Test_3.scala
@@ -0,0 +1,3 @@
+class Foo1 extends Foo
+
+class Foo2 extends Foo \ No newline at end of file
diff --git a/test/files/run/kmpSliceSearch.flags b/test/files/run/kmpSliceSearch.flags
new file mode 100644
index 0000000000..ac96850b69
--- /dev/null
+++ b/test/files/run/kmpSliceSearch.flags
@@ -0,0 +1 @@
+-Ydelambdafy:inline \ No newline at end of file
diff --git a/test/files/run/range.scala b/test/files/run/range.scala
index 4637ab874d..e50d0ac6a5 100644
--- a/test/files/run/range.scala
+++ b/test/files/run/range.scala
@@ -36,16 +36,19 @@ object Test {
def gr1 = NumericRange(x, x, x)
def gr2 = NumericRange.inclusive(x, x, x)
- def gr3 = NumericRange(x, x * fromInt(10), x)
- def gr4 = NumericRange.inclusive(x, x * fromInt(10), x)
- def gr5 = gr3.toList ::: negated.gr3.toList
+ def gr3 = NumericRange(x, x * fromInt(4), x * fromInt(2)) // SI-9348
+ def gr4 = NumericRange(x, x * fromInt(-2), x * fromInt(-2))
+ def gr5 = NumericRange(x, x * fromInt(10), x)
+ def gr6 = NumericRange.inclusive(x, x * fromInt(10), x)
+ def gr7 = gr3.toList ::: negated.gr3.toList
def check = {
assert(gr1.isEmpty && !gr2.isEmpty)
- assert(gr3.size == 9 && gr4.size == 10)
- assert(gr5.sum == num.zero, gr5.toString)
- assert(!(gr3 contains (x * fromInt(10))))
- assert((gr4 contains (x * fromInt(10))))
+ assert(gr3.size == 2 && gr4.size == 2)
+ assert(gr5.size == 9 && gr6.size == 10)
+ assert(gr7.sum == num.zero, gr7.toString)
+ assert(!(gr5 contains (x * fromInt(10))))
+ assert(gr6 contains (x * fromInt(10)))
}
}
@@ -55,6 +58,7 @@ object Test {
val _grs = List[GR[_]](
GR(BigDecimal(5.0)),
+ GR(BigDecimal(0.25)), // SI-9348
GR(BigInt(5)),
GR(5L),
GR(5.0d),
diff --git a/test/files/run/t2106.check b/test/files/run/t2106.check
index f8f625ff46..66a0e707b3 100644
--- a/test/files/run/t2106.check
+++ b/test/files/run/t2106.check
@@ -1,3 +1,10 @@
+#partest -Ybackend:GenBCode
+t2106.scala:7: warning: A::foo()Ljava/lang/Object; is annotated @inline but could not be inlined:
+The callee A::foo()Ljava/lang/Object; contains the instruction INVOKEVIRTUAL java/lang/Object.clone ()Ljava/lang/Object;
+that would cause an IllegalAccessError when inlined into class Test$.
+ def main(args: Array[String]): Unit = x.foo
+ ^
+#partest !-Ybackend:GenBCode
t2106.scala:7: warning: Could not inline required method foo because access level required by callee not matched by caller.
def main(args: Array[String]): Unit = x.foo
^
diff --git a/test/files/run/t2106.flags b/test/files/run/t2106.flags
index 00d3643fd4..a2e413bb22 100644
--- a/test/files/run/t2106.flags
+++ b/test/files/run/t2106.flags
@@ -1 +1 @@
--optimise -Yinline-warnings
+-optimise -Yinline-warnings -Yopt:l:classpath
diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala
index 52fabef6b8..d6b15a0189 100644
--- a/test/files/run/t6502.scala
+++ b/test/files/run/t6502.scala
@@ -123,7 +123,7 @@ object Test extends StoreReporterDirectTest {
}
def test6(): Unit = {
- // Avoid java.lang.NoClassDefFoundError triggered by the old appoach of using a Java
+ // Avoid java.lang.NoClassDefFoundError triggered by the old approach of using a Java
// classloader to parse .class files in order to read their names.
val jar = "test6.jar"
compileCode(app6, jar)
diff --git a/test/files/run/toolbox-varargs/Test.scala b/test/files/run/toolbox-varargs/Test.scala
new file mode 100644
index 0000000000..be5ab45768
--- /dev/null
+++ b/test/files/run/toolbox-varargs/Test.scala
@@ -0,0 +1,13 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ import scala.tools.reflect.ToolBox
+ val m = reflect.runtime.currentMirror
+ val u = m.universe
+ import u._
+ val tb = m.mkToolBox();
+ tb.compile(q"new p.Varargs(null, null)")
+ tb.compile(q"p.Varargs.staticMethod(null, null)")
+ tb.compile(q"(null: p.Varargs).instanceMethod(null, null)")
+ }
+}
+
diff --git a/test/files/run/toolbox-varargs/Varargs.java b/test/files/run/toolbox-varargs/Varargs.java
new file mode 100644
index 0000000000..da1dbbacc9
--- /dev/null
+++ b/test/files/run/toolbox-varargs/Varargs.java
@@ -0,0 +1,8 @@
+package p;
+
+public class Varargs {
+ public Varargs(String... args) {}
+ public static void staticMethod(String... args) {}
+
+ public void instanceMethod(String... args) {}
+}
diff --git a/test/junit/scala/collection/immutable/RangeConsistencyTest.scala b/test/junit/scala/collection/immutable/RangeConsistencyTest.scala
index 3980c31577..135796979d 100644
--- a/test/junit/scala/collection/immutable/RangeConsistencyTest.scala
+++ b/test/junit/scala/collection/immutable/RangeConsistencyTest.scala
@@ -137,4 +137,15 @@ class RangeConsistencyTest {
assert( (-3 to Int.MaxValue).dropWhile(_ <= 0).length == Int.MaxValue )
assert( (-3 to Int.MaxValue).span(_ <= 0) match { case (a,b) => a.length == 4 && b.length == Int.MaxValue } )
}
+
+ @Test
+ def testSI9348() {
+ // Test exclusive range with (end-start) != 0 (mod step)
+ assert( (0.0f until 0.4f by 0.25f) sameElements List(0.0f, 0.25f) )
+ assert( (1.0 until 2.2 by 0.5) sameElements List(1.0, 1.5, 2.0) )
+
+ def bd(d: Double) = BigDecimal(d)
+ val bdRange = bd(-10.0) until bd(0.0) by bd(4.5)
+ assert( bdRange sameElements List(bd(-10.0), bd(-5.5), bd(-1.0)) )
+ }
}
diff --git a/test/junit/scala/math/BigDecimalTest.scala b/test/junit/scala/math/BigDecimalTest.scala
index c7a63da890..a9e2481f37 100644
--- a/test/junit/scala/math/BigDecimalTest.scala
+++ b/test/junit/scala/math/BigDecimalTest.scala
@@ -228,4 +228,36 @@ class BigDecimalTest {
def test_SI8970() {
assert((0.1).## == BigDecimal(0.1).##)
}
+
+ // Motivated by the problem of MathContext lost
+ @Test
+ def testMathContext() {
+ def testPrecision() {
+ val p = 1000
+ val n = BigDecimal("1.1", MC.UNLIMITED).pow(p)
+
+ // BigDecimal(x: Float, mc: MC), which may not do what you want, is deprecated
+ assert(BigDecimal(1.1f, MC.UNLIMITED).pow(p) == BigDecimal(java.lang.Double.toString(1.1f.toDouble), MC.UNLIMITED).pow(p))
+ assert(BigDecimal(1.1d, MC.UNLIMITED).pow(p) == n)
+ assert(BigDecimal(new BD("1.1"), MC.UNLIMITED).pow(p) == n)
+
+ assert(BigDecimal.decimal(1.1f, MC.UNLIMITED).pow(p) == n)
+ assert(BigDecimal.decimal(1.1d, MC.UNLIMITED).pow(p) == n)
+ assert(BigDecimal.decimal(new BD("1.1"), MC.UNLIMITED).pow(p) == n)
+
+ assert((BigDecimal(11, MC.UNLIMITED) / 10).pow(p) == n)
+ assert((BigDecimal.decimal(11, MC.UNLIMITED) / 10).pow(p) == n)
+ }
+
+ def testRounded() {
+ // the default rounding mode is HALF_UP
+ assert((BigDecimal(1.23f, new MC(3)) + BigDecimal("0.005")).rounded == BigDecimal("1.24")) // deprecated api
+ assert((BigDecimal(1.23d, new MC(3)) + BigDecimal("0.005")).rounded == BigDecimal("1.24"))
+ assert((BigDecimal.decimal(1.23f, new MC(3)) + BigDecimal("0.005")).rounded == BigDecimal("1.24"))
+ assert((BigDecimal.decimal(1.23d, new MC(3)) + BigDecimal("0.005")).rounded == BigDecimal("1.24"))
+ }
+
+ testPrecision()
+ testRounded()
+ }
}
diff --git a/test/junit/scala/math/NumericTest.scala b/test/junit/scala/math/NumericTest.scala
index 9bf7d4f1e4..682dcbfd75 100644
--- a/test/junit/scala/math/NumericTest.scala
+++ b/test/junit/scala/math/NumericTest.scala
@@ -5,6 +5,9 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import scala.math.Numeric.FloatAsIfIntegral
+
+
@RunWith(classOf[JUnit4])
class NumericTest {
@@ -14,5 +17,28 @@ class NumericTest {
assertTrue(-0.0.abs equals 0.0)
assertTrue(-0.0f.abs equals 0.0f)
}
-}
+
+ /* Test for SI-9348 */
+ @Test
+ def testFloatAsIfIntegral {
+ val num = scala.math.Numeric.FloatAsIfIntegral
+ assertTrue(num.quot(1.0f, 0.5f) equals 2.0f)
+ assertTrue(num.quot(1.0f, 0.3f) equals 3.0f)
+ }
+
+ /* Test for SI-9348 */
+ @Test
+ def testDoubleAsIfIntegral {
+ val num = scala.math.Numeric.DoubleAsIfIntegral
+ assertTrue(num.quot(1.0, 0.25) equals 4.0)
+ assertTrue(num.quot(0.5, 0.15) equals 3.0)
+ }
+
+ /* Test for SI-9348 */
+ @Test
+ def testBigDecimalAsIfIntegral {
+ val num = scala.math.Numeric.BigDecimalAsIfIntegral
+ assertTrue(num.quot(BigDecimal(2.5), BigDecimal(0.5)) equals BigDecimal(5.0))
+ assertTrue(num.quot(BigDecimal(5.0), BigDecimal(2.0)) equals BigDecimal(2.0))
+ }}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala
index b4839dcec8..7ed0e13226 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerIllegalAccessTest.scala
@@ -32,7 +32,8 @@ class InlinerIllegalAccessTest extends ClearAfterClass {
import compiler.genBCode.bTypes._
def addToRepo(cls: List[ClassNode]): Unit = for (c <- cls) byteCodeRepository.add(c, ByteCodeRepository.Classfile)
- def assertEmpty(ins: Option[AbstractInsnNode]) = for (i <- ins) throw new AssertionError(textify(i))
+ def assertEmpty(ins: Option[AbstractInsnNode]) = for (i <- ins)
+ throw new AssertionError(textify(i))
@Test
def typeAccessible(): Unit = {
@@ -176,15 +177,18 @@ class InlinerIllegalAccessTest extends ClearAfterClass {
// PROTECTED
- // protected accessed in same class, or protected static accessed in subclass(rgD).
- // can be inlined to subclasses, and classes in the same package (gCl)
- for ((m, declCls) <- Set((rcC, cCl), (rgC, cCl), (rgD, dCl)); c <- Set(cCl, dCl, eCl, fCl, gCl, hCl)) check(m, declCls, c, assertEmpty)
+ // protected static accessed in same class, or protected static accessed in subclass(rgD).
+ // can be inlined to sub- and superclasses, and classes in the same package (gCl)
+ for ((m, declCls) <- Set((rgC, cCl), (rgD, dCl)); c <- Set(cCl, dCl, eCl, fCl, gCl, hCl)) check(m, declCls, c, assertEmpty)
// protected in non-subclass and different package
for (m <- Set(rcC, rgC)) check(m, cCl, iCl, cOrDOwner)
- // non-static protected accessed in subclass (rcD). can be inlined to related class, or classes in the same package
- for (c <- Set(cCl, dCl, eCl, fCl, gCl)) check(rcD, dCl, c, assertEmpty)
+ // non-static protected accessed in subclass (rcD).
+ // can be inlined only if the destination class is related (sub- or superclass) or in the same package,
+ // AND if the receiver object is a subtype of the destination class
+ // TODO: we cannot check this yet, so the check flags the instruction as causing an IllegalAccess. https://github.com/scala-opt/scala/issues/13
+ for ((m, declCls) <- Set((rcC, cCl), (rcD, dCl)); c <- Set(cCl, dCl, eCl, fCl, gCl)) check(m, declCls, c, cOrDOwner)
// rcD cannot be inlined into non-related classes, if the declaration and destination are not in the same package
for (c <- Set(hCl, iCl)) check(rcD, dCl, c, cOrDOwner)
diff --git a/test/pending/pos/t1786.scala b/test/pending/pos/t1786.scala
index 6299eb9eae..16ce4301bc 100644
--- a/test/pending/pos/t1786.scala
+++ b/test/pending/pos/t1786.scala
@@ -1,5 +1,5 @@
/** This a consequence of the current type checking algorithm, where bounds are checked only after variables are instantiated.
- * I believe this will change once we go to contraint-based type inference.
+ * I believe this will change once we go to constraint-based type inference.
* Alternatively, we can pursue a more extensive fix to SI-6169
*
* The below code shows a compiler flaw in that the wildcard "_" as value for a bounded type parameter either
diff --git a/test/pending/run/idempotency-partial-functions.scala b/test/pending/run/idempotency-partial-functions.scala
index b26c442599..c9d650ca89 100644
--- a/test/pending/run/idempotency-partial-functions.scala
+++ b/test/pending/run/idempotency-partial-functions.scala
@@ -6,7 +6,7 @@ import scala.tools.reflect.Eval
// Related to SI-6187
//
// Moved to pending as we are currently blocked by the inability
-// to reify the parent types of the anoymous function class,
+// to reify the parent types of the anonymous function class,
// which are not part of the tree, but rather only part of the
// ClassInfoType.
object Test extends App {
diff --git a/test/scaladoc/resources/implicits-base-res.scala b/test/scaladoc/resources/implicits-base-res.scala
index 1d17e9a6d3..559d21997f 100644
--- a/test/scaladoc/resources/implicits-base-res.scala
+++ b/test/scaladoc/resources/implicits-base-res.scala
@@ -52,7 +52,7 @@ object A {
* def convToGtColonDoubleA(x: Double) // enrichA3: no constraints
* def convToManifestA(x: Double) // enrichA7: no constraints
* def convToMyNumericA(x: Double) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope
- * def convToNumericA(x: Double) // enrichA1: no constraintsd
+ * def convToNumericA(x: Double) // enrichA1: no constraints
* def convToEnrichedA(x: Bar[Foo[Double]]) // enrichA5: no constraints, SHADOWED
* def convToEnrichedA(x: Double) // enrichA0: no constraints, SHADOWED
* def convToTraversableOps(x: Double) // enrichA7: no constraints
diff --git a/test/scaladoc/run/implicits-base.scala b/test/scaladoc/run/implicits-base.scala
index 8f8652cdb3..ea87a670bb 100644
--- a/test/scaladoc/run/implicits-base.scala
+++ b/test/scaladoc/run/implicits-base.scala
@@ -94,7 +94,7 @@ object Test extends ScaladocModelTest {
assert(isShadowed(conv._member("convToEnrichedA")))
assert(conv._member("convToEnrichedA").resultType.name == "Double")
- // def convToNumericA: Double // enrichA1: no constraintsd
+ // def convToNumericA: Double // enrichA1: no constraints
conv = B._conversion(A.qualifiedName + ".enrichA1")
assert(conv.members.length == 1)
assert(conv.constraints.length == 0)
diff --git a/test/scaladoc/scalacheck/HtmlFactoryTest.scala b/test/scaladoc/scalacheck/HtmlFactoryTest.scala
index 6a6b1f8901..578e0382eb 100644
--- a/test/scaladoc/scalacheck/HtmlFactoryTest.scala
+++ b/test/scaladoc/scalacheck/HtmlFactoryTest.scala
@@ -711,7 +711,7 @@ object Test extends Properties("HtmlFactory") {
property("class") = files.get("com/example/p1/Clazz.html") match {
case Some(node: scala.xml.Node) => {
- property("implicit convertion") =
+ property("implicit conversion") =
node.toString contains "<span class=\"modifier\">implicit </span>"
property("gt4s") =