summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml6
-rw-r--r--src/compiler/scala/reflect/internal/Importers.scala2
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala10
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala4
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/transform/LiftCode.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/compiler/scala/tools/util/EditDistance.scala31
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala2
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala19
-rw-r--r--src/library/scala/collection/GenSeqLike.scala4
-rw-r--r--src/library/scala/collection/TraversableLike.scala4
-rw-r--r--src/library/scala/math/package.scala12
-rw-r--r--test/files/jvm/signum.scala15
-rw-r--r--test/files/neg/nopredefs.check2
-rw-r--r--test/files/neg/suggest-similar.check9
-rw-r--r--test/files/neg/suggest-similar.flags1
-rw-r--r--test/files/neg/suggest-similar.scala2
-rw-r--r--test/files/neg/t2870.check2
-rw-r--r--test/files/run/t5230.check2
-rw-r--r--test/files/run/t5230.scala (renamed from test/pending/run/t5230.scala)0
-rw-r--r--test/pending/run/t5230.check1
22 files changed, 78 insertions, 55 deletions
diff --git a/build.xml b/build.xml
index 3b8dd4661c..161c23f6d9 100644
--- a/build.xml
+++ b/build.xml
@@ -649,7 +649,7 @@ QUICK BUILD (QUICK)
<scalacfork
destdir="${build-quick.dir}/classes/library"
compilerpathref="quick.classpath"
- params="${scalac.args.quick} -Xplugin-require:continuations -P:continuations:enable"
+ params="${scalac.args.quick} -Xplugin-require:continuations"
srcdir="${src.dir}/continuations/library"
jvmargs="${scalacfork.jvmargs}">
<include name="**/*.scala"/>
@@ -1164,7 +1164,7 @@ BOOTSTRAPPING BUILD (STRAP)
<scalacfork
destdir="${build-strap.dir}/classes/library"
compilerpathref="pack.classpath"
- params="${scalac.args.all} -Xplugin-require:continuations -P:continuations:enable"
+ params="${scalac.args.all} -Xplugin-require:continuations"
srcdir="${src.dir}/continuations/library"
jvmargs="${scalacfork.jvmargs}">
<include name="**/*.scala"/>
@@ -1624,7 +1624,7 @@ BOOTRAPING TEST AND TEST SUITE
<partest showlog="yes" erroronfailed="yes" javacmd="${java.home}/bin/java"
timeout="2400000"
srcdir="${partest.srcdir}"
- scalacopts="${scalac.args.optimise} -Xplugin-require:continuations -P:continuations:enable">
+ scalacopts="${scalac.args.optimise} -Xplugin-require:continuations">
<compilerarg value="-Xpluginsdir"/>
<compilerarg file="${build-quick.dir}/misc/scala-devel/plugins"/>
<compilationpath>
diff --git a/src/compiler/scala/reflect/internal/Importers.scala b/src/compiler/scala/reflect/internal/Importers.scala
index 6d672d9263..60b353a7c4 100644
--- a/src/compiler/scala/reflect/internal/Importers.scala
+++ b/src/compiler/scala/reflect/internal/Importers.scala
@@ -231,6 +231,8 @@ trait Importers { self: SymbolTable =>
new PackageDef(importRefTree(pid), stats map importTree)
case from.ModuleDef(mods, name, impl) =>
new ModuleDef(importModifiers(mods), importName(name).toTermName, importTemplate(impl))
+ case from.emptyValDef =>
+ emptyValDef
case from.ValDef(mods, name, tpt, rhs) =>
new ValDef(importModifiers(mods), importName(name).toTermName, importTree(tpt), importTree(rhs))
case from.DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 320fb949ff..265261f594 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -4174,8 +4174,16 @@ A type's typeSymbol should never be inspected directly.
private def adaptToNewRun(pre: Type, sym: Symbol): Symbol = {
if (phase.flatClasses) {
sym
+ } else if (sym == definitions.RootClass) {
+ definitions.RootClass
+ } else if (sym == definitions.RootPackage) {
+ definitions.RootPackage
} else if (sym.isModuleClass) {
- adaptToNewRun(pre, sym.sourceModule).moduleClass
+ val sourceModule1 = adaptToNewRun(pre, sym.sourceModule)
+ val result = sourceModule1.moduleClass
+ val msg = "sym = %s, sourceModule = %s, sourceModule.moduleClass = %s => sourceModule1 = %s, sourceModule1.moduleClass = %s"
+ assert(result != NoSymbol, msg.format(sym, sym.sourceModule, sym.sourceModule.moduleClass, sourceModule1, sourceModule1.moduleClass))
+ result
} else if ((pre eq NoPrefix) || (pre eq NoType) || sym.isPackageClass) {
sym
} else {
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 9668debbbb..85849cfad4 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -257,6 +257,10 @@ trait Trees extends reflect.internal.Trees { self: Global =>
case _: DefTree | Function(_, _) | Template(_, _, _) =>
resetDef(tree)
tree.tpe = null
+ tree match {
+ case tree: DefDef => tree.tpt.tpe = null
+ case _ => ()
+ }
case tpt: TypeTree =>
if (tpt.wasEmpty) tree.tpe = null
case This(_) if tree.symbol != null && tree.symbol.isPackageClass =>
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 1f8fa5bbe2..6be15e4e98 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -178,7 +178,6 @@ trait ScalaSettings extends AbsScalaSettings
val exposeEmptyPackage = BooleanSetting("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
val YnoProductN = BooleanSetting ("-Yno-productN", "Do not add ProductN to case classes")
- val suggestIdents = BooleanSetting("-Ysuggest-idents", "Suggest alternatives for `not found` identifiers")
def stop = stopAfter
diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
index 7a64fc9b5e..68a53e57a1 100644
--- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala
+++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
@@ -475,7 +475,7 @@ abstract class LiftCode extends Transform with TypingTransformers {
case tt: TypeTree if (tt.tpe != null) =>
if (!(boundSyms exists (tt.tpe contains _))) mirrorCall("TypeTree", reifyType(tt.tpe))
else if (tt.original != null) reify(tt.original)
- else TypeTree()
+ else mirrorCall("TypeTree")
case global.emptyValDef =>
mirrorSelect("emptyValDef")
case _ =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 30d10325be..7671ccbed7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3874,7 +3874,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
else {
val similar = (
// name length check to limit unhelpful suggestions for e.g. "x" and "b1"
- if (settings.suggestIdents.value && name.length > 2) {
+ if (name.length > 2) {
val allowed = (
startingIdentContext.enclosingContextChain
flatMap (ctx => ctx.scope.toList ++ ctx.imports.flatMap(_.allImportedSymbols))
diff --git a/src/compiler/scala/tools/util/EditDistance.scala b/src/compiler/scala/tools/util/EditDistance.scala
index 704286d47e..a8d7408532 100644
--- a/src/compiler/scala/tools/util/EditDistance.scala
+++ b/src/compiler/scala/tools/util/EditDistance.scala
@@ -8,22 +8,22 @@ package util
object EditDistance {
def similarString(name: String, allowed: TraversableOnce[String]): String = {
- val suggested = suggestions(name, allowed.toSeq, maxDistance = 2, maxSuggestions = 2)
- if (suggested.isEmpty) ""
+ val suggested = suggestions(name, allowed.toSeq, maxDistance = 1, maxSuggestions = 2)
+ if (suggested.isEmpty) ""
else suggested.mkString(" (similar: ", ", ", ")")
}
- def suggestions(a: String, bs: Seq[String], maxDistance: Int = 3, maxSuggestions: Int = 3): Seq[String] =
- bs.map { b => (b, distance(a, b) ) } filter (_._2 <= maxDistance) sortBy(_._2) take(maxSuggestions) map(_._1)
+ def suggestions(a: String, bs: Seq[String], maxDistance: Int, maxSuggestions: Int): Seq[String] = (
+ bs map (b => (b, distance(a, b)))
+ filter (_._2 <= maxDistance)
+ sortBy (_._2)
+ take (maxSuggestions)
+ map (_._1)
+ )
- def distance(a: String, b: String): Int =
- levenshtein(a, b, insertCost = 1, deleteCost = 1, subCost = 2, transposeCost = 1, matchCost = -1, true)
+ def distance(a: String, b: String): Int = levenshtein(a, b, transpositions = true)
- /** Translated from the java version at
- * http://www.merriampark.com/ld.htm
- * which is declared to be public domain.
- */
- def levenshtein(s: String, t: String, insertCost: Int = 1, deleteCost: Int = 1, subCost: Int = 1, transposeCost: Int = 1, matchCost: Int = 0, transpositions: Boolean = false): Int = {
+ def levenshtein(s: String, t: String, transpositions: Boolean): Int = {
val n = s.length
val m = t.length
if (n == 0) return m
@@ -35,18 +35,17 @@ object EditDistance {
for (i <- 1 to n ; val s_i = s(i - 1) ; j <- 1 to m) {
val t_j = t(j - 1)
- val cost = if (s_i == t_j) matchCost else subCost
- val tcost = if (s_i == t_j) matchCost else transposeCost
+ val cost = if (s_i == t_j) 0 else 1
- val c1 = d(i - 1)(j) + deleteCost
- val c2 = d(i)(j - 1) + insertCost
+ val c1 = d(i - 1)(j) + 1
+ val c2 = d(i)(j - 1) + 1
val c3 = d(i - 1)(j - 1) + cost
d(i)(j) = c1 min c2 min c3
if (transpositions) {
if (i > 1 && j > 1 && s(i - 1) == t(j - 2) && s(i - 2) == t(j - 1))
- d(i)(j) = d(i)(j) min (d(i - 2)(j - 2) + cost)
+ d(i)(j) = d(i)(j) min (d(i - 2)(j - 2) + cost)
}
}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
index 5cb06d42db..f4481b800e 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
@@ -9,7 +9,7 @@ trait CPSUtils {
import global._
import definitions._
- var cpsEnabled = false
+ var cpsEnabled = true
val verbose: Boolean = System.getProperty("cpsVerbose", "false") == "true"
def vprintln(x: =>Any): Unit = if (verbose) println(x)
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
index 8a500d6c4d..eb18f03748 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
@@ -26,7 +26,6 @@ class SelectiveCPSPlugin(val global: Global) extends Plugin {
override val runsBefore = List("uncurry")
}
-
val components = List[PluginComponent](anfPhase, cpsPhase)
val checker = new CPSAnnotationChecker {
@@ -43,19 +42,17 @@ class SelectiveCPSPlugin(val global: Global) extends Plugin {
}
// TODO: require -enabled command-line flag
-
override def processOptions(options: List[String], error: String => Unit) = {
- var enabled = false
- for (option <- options) {
- if (option == "enable") {
- enabled = true
- } else {
- error("Option not understood: "+option)
- }
+ var enabled = true
+ options foreach {
+ case "enable" => enabled = true
+ case "disable" => enabled = false
+ case option => error("Option not understood: "+option)
}
setEnabled(enabled)
}
- override val optionsHelp: Option[String] =
- Some(" -P:continuations:enable Enable continuations")
+ override val optionsHelp: Option[String] = {
+ Some(" -P:continuations:disable Disable continuations plugin")
+ }
}
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index b3dd4764a9..63e9543711 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -276,6 +276,8 @@ trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Pa
/** A copy of the $coll with an element prepended.
*
* Note that :-ending operators are right associative (see example).
+ * A mnemonic for `+:` vs. `:+` is: the COLon goes on the COLlection side.
+ *
* Also, the original $coll is not modified, so you will want to capture the result.
*
* Example:
@@ -304,6 +306,8 @@ trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Pa
/** A copy of this $coll with an element appended.
*
+ * A mnemonic for `+:` vs. `:+` is: the COLon goes on the COLlection side.
+ *
* $willNotTerminateInf
* @param elem the appended element
* @tparam B the element type of the returned $coll.
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 6fa05bd85b..4f0fec1de3 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -159,8 +159,10 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
/** As with `++`, returns a new collection containing the elements from the left operand followed by the
* elements from the right operand.
+ *
* It differs from `++` in that the right operand determines the type of
* the resulting collection rather than the left one.
+ * Mnemonic: the COLon is on the side of the new COLlection type.
*
* Example:
* {{{
@@ -195,8 +197,10 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
/** As with `++`, returns a new collection containing the elements from the
* left operand followed by the elements from the right operand.
+ *
* It differs from `++` in that the right operand determines the type of
* the resulting collection rather than the left one.
+ * Mnemonic: the COLon is on the side of the new COLlection type.
*
* Example:
* {{{
diff --git a/src/library/scala/math/package.scala b/src/library/scala/math/package.scala
index 8948722340..0417461f85 100644
--- a/src/library/scala/math/package.scala
+++ b/src/library/scala/math/package.scala
@@ -127,15 +127,9 @@ package object math {
else if (x > 0) 1.0f
else x // NaN
- def signum(x: Long): Long =
- if (x == 0l) 0l
- else if (x < 0) -1l
- else 1l
-
- def signum(x: Int): Int =
- if (x == 0) 0
- else if (x < 0) -1
- else 1
+ def signum(x: Long): Long = java.lang.Long.signum(x)
+
+ def signum(x: Int): Int = java.lang.Integer.signum(x)
// -----------------------------------------------------------------------
// root functions
diff --git a/test/files/jvm/signum.scala b/test/files/jvm/signum.scala
new file mode 100644
index 0000000000..feb28d3e43
--- /dev/null
+++ b/test/files/jvm/signum.scala
@@ -0,0 +1,15 @@
+object Test {
+ def main(args: Array[String]) {
+ assert(math.signum(Long.MaxValue) == 1L)
+ assert(math.signum(1L) == 1L)
+ assert(math.signum(0L) == 0L)
+ assert(math.signum(-1L) == -1L)
+ assert(math.signum(Long.MinValue) == -1L)
+
+ assert(math.signum(Int.MaxValue) == 1)
+ assert(math.signum(1) == 1)
+ assert(math.signum(0) == 0)
+ assert(math.signum(-1) == -1)
+ assert(math.signum(Int.MinValue) == -1)
+ }
+}
diff --git a/test/files/neg/nopredefs.check b/test/files/neg/nopredefs.check
index 0a0ab34482..e6c1af78a0 100644
--- a/test/files/neg/nopredefs.check
+++ b/test/files/neg/nopredefs.check
@@ -1,4 +1,4 @@
-nopredefs.scala:5: error: not found: value Set
+nopredefs.scala:5: error: not found: value Set (similar: Seq)
val y = Set(3)
^
one error found
diff --git a/test/files/neg/suggest-similar.check b/test/files/neg/suggest-similar.check
index 320c7d0092..0a858aaf2e 100644
--- a/test/files/neg/suggest-similar.check
+++ b/test/files/neg/suggest-similar.check
@@ -1,13 +1,10 @@
suggest-similar.scala:8: error: not found: value flippitx (similar: flippity)
flippitx = 123
^
-suggest-similar.scala:9: error: not found: value identipoo (similar: identity)
- Nil map identipoo
+suggest-similar.scala:9: error: not found: value identiyt (similar: identity)
+ Nil map identiyt
^
suggest-similar.scala:10: error: not found: type Bingus (similar: Dingus)
new Bingus
^
-suggest-similar.scala:11: error: value bap is not a member of object Nil
- Nil bap identity
- ^
-four errors found
+three errors found
diff --git a/test/files/neg/suggest-similar.flags b/test/files/neg/suggest-similar.flags
deleted file mode 100644
index 66bb23c396..0000000000
--- a/test/files/neg/suggest-similar.flags
+++ /dev/null
@@ -1 +0,0 @@
--Ysuggest-idents \ No newline at end of file
diff --git a/test/files/neg/suggest-similar.scala b/test/files/neg/suggest-similar.scala
index ae18c6ea62..ff327478fe 100644
--- a/test/files/neg/suggest-similar.scala
+++ b/test/files/neg/suggest-similar.scala
@@ -6,6 +6,6 @@ import Dingus._
class A {
flippitx = 123
- Nil map identipoo
+ Nil map identiyt
new Bingus
}
diff --git a/test/files/neg/t2870.check b/test/files/neg/t2870.check
index 6577577d3f..72bc0d98a1 100644
--- a/test/files/neg/t2870.check
+++ b/test/files/neg/t2870.check
@@ -1,4 +1,4 @@
-t2870.scala:1: error: not found: type Jar
+t2870.scala:1: error: not found: type Jar (similar: Jars)
class Jars(jar: Jar)
^
t2870.scala:6: error: illegal cyclic reference involving value <import>
diff --git a/test/files/run/t5230.check b/test/files/run/t5230.check
new file mode 100644
index 0000000000..5db6ec9b38
--- /dev/null
+++ b/test/files/run/t5230.check
@@ -0,0 +1,2 @@
+2
+evaluated = null
diff --git a/test/pending/run/t5230.scala b/test/files/run/t5230.scala
index 5aab8f9290..5aab8f9290 100644
--- a/test/pending/run/t5230.scala
+++ b/test/files/run/t5230.scala
diff --git a/test/pending/run/t5230.check b/test/pending/run/t5230.check
deleted file mode 100644
index 5ef4ff4d04..0000000000
--- a/test/pending/run/t5230.check
+++ /dev/null
@@ -1 +0,0 @@
-evaluated = 2