summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/StringContext.scala2
-rw-r--r--src/library/scala/concurrent/package.scala5
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala13
-rw-r--r--test/files/pos/t6648.scala24
-rw-r--r--test/files/run/rawstrings.check2
-rw-r--r--test/files/run/rawstrings.scala2
-rw-r--r--test/files/run/t6559.scala17
7 files changed, 59 insertions, 6 deletions
diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala
index f72547724d..8be0cb1619 100644
--- a/src/library/scala/StringContext.scala
+++ b/src/library/scala/StringContext.scala
@@ -120,7 +120,7 @@ case class StringContext(parts: String*) {
val bldr = new java.lang.StringBuilder(process(pi.next()))
while (ai.hasNext) {
bldr append ai.next
- bldr append treatEscapes(pi.next())
+ bldr append process(pi.next())
}
bldr.toString
}
diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala
index f7c732b851..3e849f1722 100644
--- a/src/library/scala/concurrent/package.scala
+++ b/src/library/scala/concurrent/package.scala
@@ -29,13 +29,12 @@ package object concurrent {
*/
def future[T](body: =>T)(implicit execctx: ExecutionContext): Future[T] = Future[T](body)
- /** Creates a promise object which can be completed with a value.
+ /** Creates a promise object which can be completed with a value or an exception.
*
* @tparam T the type of the value in the promise
- * @param execctx the execution context on which the promise is created on
* @return the newly created `Promise` object
*/
- def promise[T]()(implicit execctx: ExecutionContext): Promise[T] = Promise[T]()
+ def promise[T](): Promise[T] = Promise[T]()
/** Used to designate a piece of code which potentially blocks, allowing the current [[BlockContext]] to adjust
* the runtime's behavior.
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index 53b40da8f6..b8f5e73acb 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -482,6 +482,10 @@ trait Trees extends api.Trees { self: SymbolTable =>
case class TypeTree() extends TypTree with TypeTreeContextApi {
private var orig: Tree = null
+ /** Was this type tree originally empty? That is, does it now contain
+ * an inferred type that must be forgotten in `resetAttrs` to
+ * enable retyping.
+ */
private[scala] var wasEmpty: Boolean = false
override def symbol = typeTreeSymbol(this) // if (tpe == null) null else tpe.typeSymbol
@@ -502,6 +506,15 @@ trait Trees extends api.Trees { self: SymbolTable =>
wasEmpty = isEmpty
setType(tp)
}
+
+ override private[scala] def copyAttrs(tree: Tree) = {
+ super.copyAttrs(tree)
+ tree match {
+ case other: TypeTree => wasEmpty = other.wasEmpty // SI-6648 Critical for correct operation of `resetAttrs`.
+ case _ =>
+ }
+ this
+ }
}
object TypeTree extends TypeTreeExtractor
diff --git a/test/files/pos/t6648.scala b/test/files/pos/t6648.scala
new file mode 100644
index 0000000000..9593ebfee9
--- /dev/null
+++ b/test/files/pos/t6648.scala
@@ -0,0 +1,24 @@
+abstract class Node extends NodeSeq
+trait NodeSeq extends Seq[Node]
+object NodeSeq {
+ implicit def seqToNodeSeq(ns: Seq[Node]): NodeSeq = ???
+ def foo[B, That](f: Seq[B])(implicit bf: scala.collection.generic.CanBuildFrom[Seq[Int], B, That]): That = ???
+}
+
+class Transformer {
+ def apply(nodes: Any): Any = ???
+}
+
+object transformer1 extends Transformer {
+ // Adding explicit type arguments, or making the impilcit view
+ // seqToNodeSeq explicit avoids the crash
+ NodeSeq.foo {
+ // These both avoid the crash:
+ // val t = new Transformer {}; t.apply(null)
+ // new Transformer().apply(null)
+ new Transformer {}.apply(null)
+
+ null: NodeSeq
+ }: NodeSeq
+}
+
diff --git a/test/files/run/rawstrings.check b/test/files/run/rawstrings.check
index 36e63594df..2b6c40725a 100644
--- a/test/files/run/rawstrings.check
+++ b/test/files/run/rawstrings.check
@@ -1 +1 @@
-[\n\t'"$]
+[\n\t'"$\n]
diff --git a/test/files/run/rawstrings.scala b/test/files/run/rawstrings.scala
index 9df64f6625..b4d6e0c40a 100644
--- a/test/files/run/rawstrings.scala
+++ b/test/files/run/rawstrings.scala
@@ -1,3 +1,3 @@
object Test extends App {
- println(raw"[\n\t'${'"'}$$]")
+ println(raw"[\n\t'${'"'}$$\n]")
}
diff --git a/test/files/run/t6559.scala b/test/files/run/t6559.scala
new file mode 100644
index 0000000000..5c671f7275
--- /dev/null
+++ b/test/files/run/t6559.scala
@@ -0,0 +1,17 @@
+
+object Test {
+
+ def main(args: Array[String]) = {
+ val one = "1"
+ val two = "2"
+
+ val raw = raw"\n$one\n$two\n"
+ val escaped = s"\n$one\n$two\n"
+ val buggy = "\\n1\n2\n"
+ val correct = "\\n1\\n2\\n"
+
+ assert(raw != escaped, "Raw strings should not be escaped.")
+ assert(raw != buggy, "Raw strings after variables should not be escaped.")
+ assert(raw == correct, "Raw strings should stay raw.")
+ }
+}