summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.sbt24
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala4
-rw-r--r--src/library/scala/collection/immutable/StringLike.scala1
-rw-r--r--src/library/scala/sys/process/ProcessBuilder.scala8
-rw-r--r--src/library/scala/sys/process/package.scala10
-rw-r--r--src/reflect/scala/reflect/internal/Printers.scala2
-rw-r--r--src/reflect/scala/reflect/internal/TypeDebugging.scala2
-rw-r--r--test/files/run/t9806.scala18
-rw-r--r--test/files/run/t9841.scala24
-rw-r--r--test/junit/scala/reflect/internal/PrintersTest.scala8
10 files changed, 78 insertions, 23 deletions
diff --git a/build.sbt b/build.sbt
index 3df0d43c00..3b0c74a0ee 100644
--- a/build.sbt
+++ b/build.sbt
@@ -220,7 +220,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings +
// directly to stdout
outputStrategy in run := Some(StdoutOutput),
Quiet.silenceScalaBinaryVersionWarning
-)
+) ++ removePomDependencies
/** Extra post-processing for the published POM files. These are needed to create POMs that
* are equivalent to the ones from the ANT build. In the long term this should be removed and
@@ -249,10 +249,16 @@ def fixPom(extra: (String, scala.xml.Node)*): Setting[_] = {
) ++ extra) }
}
+val pomDependencyExclusions =
+ settingKey[Seq[(String, String)]]("List of (groupId, artifactId) pairs to exclude from the POM and ivy.xml")
+
+pomDependencyExclusions in Global := Nil
+
/** Remove unwanted dependencies from the POM and ivy.xml. */
-def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq(
+lazy val removePomDependencies: Seq[Setting[_]] = Seq(
pomPostProcess := { n =>
val n2 = pomPostProcess.value.apply(n)
+ val deps = pomDependencyExclusions.value
import scala.xml._
import scala.xml.transform._
new RuleTransformer(new RewriteRule {
@@ -270,6 +276,7 @@ def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq(
import scala.xml._
import scala.xml.transform._
val f = deliverLocal.value
+ val deps = pomDependencyExclusions.value
val e = new RuleTransformer(new RewriteRule {
override def transform(node: Node) = node match {
case e: Elem if e.label == "dependency" && {
@@ -366,10 +373,10 @@ lazy val library = configureAsSubproject(project)
"/project/name" -> <name>Scala Library</name>,
"/project/description" -> <description>Standard library for the Scala Programming Language</description>,
"/project/packaging" -> <packaging>jar</packaging>
- )
+ ),
+ // Remove the dependency on "forkjoin" from the POM because it is included in the JAR:
+ pomDependencyExclusions += ((organization.value, "forkjoin"))
)
- // Remove the dependency on "forkjoin" from the POM because it is included in the JAR:
- .settings(removePomDependencies(("org.scala-lang", "forkjoin")): _*)
.settings(filterDocSources("*.scala" -- (regexFileFilter(".*/runtime/.*\\$\\.scala") ||
regexFileFilter(".*/runtime/ScalaRunTime\\.scala") ||
regexFileFilter(".*/runtime/StringAdd\\.scala"))): _*)
@@ -451,12 +458,9 @@ lazy val compiler = configureAsSubproject(project)
"/project/description" -> <description>Compiler for the Scala Programming Language</description>,
"/project/packaging" -> <packaging>jar</packaging>
),
- apiURL := None
+ apiURL := None,
+ pomDependencyExclusions ++= List(("org.apache.ant", "ant"), ("org.scala-lang.modules", "scala-asm"))
)
- .settings(removePomDependencies(
- ("org.apache.ant", "ant"),
- ("org.scala-lang.modules", "scala-asm")
- ): _*)
.dependsOn(library, reflect)
lazy val interactive = configureAsSubproject(project)
diff --git a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
index a7ce7dfa04..eafaf41932 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
@@ -539,14 +539,14 @@ abstract class ConstantOptimization extends SubComponent {
// number of instructions excluding the last one
val normalCount = block.size - 1
- val exceptionState = in.cleanStack
+ var exceptionState = in.cleanStack
var normalExitState = in
var idx = 0
while (idx < normalCount) {
val inst = block(idx)
normalExitState = interpretInst(normalExitState, inst)
if (normalExitState.locals ne exceptionState.locals)
- exceptionState.copy(locals = exceptionState mergeLocals normalExitState.locals)
+ exceptionState = exceptionState.copy(locals = exceptionState mergeLocals normalExitState.locals)
idx += 1
}
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala
index 1b52e40b72..232d67df4f 100644
--- a/src/library/scala/collection/immutable/StringLike.scala
+++ b/src/library/scala/collection/immutable/StringLike.scala
@@ -137,6 +137,7 @@ self =>
/** Returns this string with first character converted to upper case.
* If the first character of the string is capitalized, it is returned unchanged.
+ * This method does not convert characters outside the Basic Multilingual Plane (BMP).
*/
def capitalize: String =
if (toString == null) null
diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala
index ac86495001..e4344a857e 100644
--- a/src/library/scala/sys/process/ProcessBuilder.scala
+++ b/src/library/scala/sys/process/ProcessBuilder.scala
@@ -90,19 +90,19 @@ import ProcessBuilder._
*
* If not specified, the input of the external commands executed with `run` or
* `!` will not be tied to anything, and the output will be redirected to the
- * stdout and stderr of the Scala process. For the methods `!!` and `lines`, no
+ * stdout and stderr of the Scala process. For the methods `!!` and `lineStream`, no
* input will be provided, and the output will be directed according to the
* semantics of these methods.
*
* Some methods will cause stdin to be used as input. Output can be controlled
- * with a [[scala.sys.process.ProcessLogger]] -- `!!` and `lines` will only
+ * with a [[scala.sys.process.ProcessLogger]] -- `!!` and `lineStream` will only
* redirect error output when passed a `ProcessLogger`. If one desires full
* control over input and output, then a [[scala.sys.process.ProcessIO]] can be
* used with `run`.
*
- * For example, we could silence the error output from `lines_!` like this:
+ * For example, we could silence the error output from `lineStream_!` like this:
* {{{
- * val etcFiles = "find /etc" lines_! ProcessLogger(line => ())
+ * val etcFiles = "find /etc" lineStream_! ProcessLogger(line => ())
* }}}
*
* ==Extended Example==
diff --git a/src/library/scala/sys/process/package.scala b/src/library/scala/sys/process/package.scala
index 445c3aee60..ac6ab8f670 100644
--- a/src/library/scala/sys/process/package.scala
+++ b/src/library/scala/sys/process/package.scala
@@ -25,7 +25,7 @@ package scala.sys {
*
* {{{
* import scala.sys.process._
- * "ls" #| "grep .scala" #&& Seq("sh", "-c", "scalac *.scala") #|| "echo nothing found" lines
+ * "ls" #| "grep .scala" #&& Seq("sh", "-c", "scalac *.scala") #|| "echo nothing found" lineStream
* }}}
*
* We describe below the general concepts and architecture of the package,
@@ -92,7 +92,7 @@ package scala.sys {
*
* - Return status of the process (`!` methods)
* - Output of the process as a `String` (`!!` methods)
- * - Continuous output of the process as a `Stream[String]` (`lines` methods)
+ * - Continuous output of the process as a `Stream[String]` (`lineStream` methods)
* - The `Process` representing it (`run` methods)
*
* Some simple examples of these methods:
@@ -109,7 +109,7 @@ package scala.sys {
* // a Stream[String]
* def sourceFilesAt(baseDir: String): Stream[String] = {
* val cmd = Seq("find", baseDir, "-name", "*.scala", "-type", "f")
- * cmd.lines
+ * cmd.lineStream
* }
* }}}
*
@@ -167,8 +167,8 @@ package scala.sys {
* def sourceFilesAt(baseDir: String): (Stream[String], StringBuffer) = {
* val buffer = new StringBuffer()
* val cmd = Seq("find", baseDir, "-name", "*.scala", "-type", "f")
- * val lines = cmd lines_! ProcessLogger(buffer append _)
- * (lines, buffer)
+ * val lineStream = cmd lineStream_! ProcessLogger(buffer append _)
+ * (lineStream, buffer)
* }
* }}}
*
diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala
index b44c4022f6..9a5314192f 100644
--- a/src/reflect/scala/reflect/internal/Printers.scala
+++ b/src/reflect/scala/reflect/internal/Printers.scala
@@ -1050,7 +1050,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
x match {
case Constant(v: String) if {
val strValue = x.stringValue
- strValue.contains(LF) && strValue.contains("\"\"\"") && strValue.size > 1
+ strValue.contains(LF) && !strValue.contains("\"\"\"") && strValue.size > 1
} =>
val splitValue = x.stringValue.split(s"$LF").toList
val multilineStringValue = if (x.stringValue.endsWith(s"$LF")) splitValue :+ "" else splitValue
diff --git a/src/reflect/scala/reflect/internal/TypeDebugging.scala b/src/reflect/scala/reflect/internal/TypeDebugging.scala
index 63f897cd32..4a5128feeb 100644
--- a/src/reflect/scala/reflect/internal/TypeDebugging.scala
+++ b/src/reflect/scala/reflect/internal/TypeDebugging.scala
@@ -110,7 +110,7 @@ trait TypeDebugging {
val hi_s = if (noPrint(hi)) "" else " <: " + ptTree(hi)
lo_s + hi_s
case _ if (t.symbol eq null) || (t.symbol eq NoSymbol) => to_s(t)
- case _ => "" + t.symbol.tpe
+ case _ => if (t.symbol.hasCompleteInfo) "" + t.symbol.tpe else "<?>"
}
def ptTypeParam(td: TypeDef): String = {
val TypeDef(_, name, tparams, rhs) = td
diff --git a/test/files/run/t9806.scala b/test/files/run/t9806.scala
new file mode 100644
index 0000000000..ccde989efe
--- /dev/null
+++ b/test/files/run/t9806.scala
@@ -0,0 +1,18 @@
+object Ex extends Exception
+object Test {
+ def main(args: Array[String]) {
+ try foo catch { case Ex => }
+ }
+
+ def isTrue(b: Boolean) = b
+ def foo = {
+ var streamErrors1 = true
+ try {
+ streamErrors1 = false
+ throw Ex
+ } catch {
+ case ex if streamErrors1 =>
+ assert(isTrue(streamErrors1))
+ }
+ }
+}
diff --git a/test/files/run/t9841.scala b/test/files/run/t9841.scala
new file mode 100644
index 0000000000..19cfef28a5
--- /dev/null
+++ b/test/files/run/t9841.scala
@@ -0,0 +1,24 @@
+// SI-9841 regrettable behavior initializing private inner object
+// A fix is not yet planned for 2.11.9, but it works in 2.12.x.
+//
+//at Container.Container$$Inner$lzycompute(t9841.scala:4)
+//at Container.Container$$Inner(t9841.scala:4)
+//at Container$Inner$.<init>(t9841.scala:5)
+//
+class Container {
+ private case class Inner(s: String)
+ private object Inner {
+ val Empty = Inner("")
+ }
+ private val state = Inner.Empty
+}
+
+object Test extends App {
+ val catcher: PartialFunction[Throwable, Unit] = {
+ case _: StackOverflowError =>
+ }
+ try {
+ new Container
+ Console println "Expected StackOverflowError"
+ } catch catcher
+}
diff --git a/test/junit/scala/reflect/internal/PrintersTest.scala b/test/junit/scala/reflect/internal/PrintersTest.scala
index 9bfe6eecb8..cacff6a012 100644
--- a/test/junit/scala/reflect/internal/PrintersTest.scala
+++ b/test/junit/scala/reflect/internal/PrintersTest.scala
@@ -86,6 +86,14 @@ trait BasePrintTests {
@Test def testConstantLong = assertTreeCode(Literal(Constant(42l)))("42L")
+ @Test def testConstantMultiline = assertTreeCode(Literal(Constant("hello\nworld")))("\"\"\"hello\nworld\"\"\"")
+
+ val sq = "\""
+ val teq = "\\\"" * 3
+ val tq = "\"" * 3
+
+ @Test def testConstantEmbeddedTriple = assertTreeCode(Literal(Constant(s"${tq}hello${tq}\nworld")))(s"${sq}${teq}hello${teq}\\nworld${sq}")
+
@Test def testOpExpr = assertPrintedCode("(5).+(4)", checkTypedTree = false)
@Test def testName1 = assertPrintedCode("class test")