summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala4
-rw-r--r--src/library/scala/concurrent/package.scala5
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala80
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala13
-rw-r--r--test/files/pos/t6648.scala24
-rw-r--r--test/files/run/t6644.scala8
-rw-r--r--test/files/run/t6646.check5
-rw-r--r--test/files/run/t6646.scala19
-rwxr-xr-xtools/epfl-publish2
10 files changed, 136 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 0d13623e0c..0ac46a18bc 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -285,7 +285,7 @@ abstract class TreeBuilder {
def makeGenerator(pos: Position, pat: Tree, valeq: Boolean, rhs: Tree): Enumerator = {
val pat1 = patvarTransformer.transform(pat)
val rhs1 =
- if (valeq || treeInfo.isVariablePattern(pat)) rhs
+ if (valeq || treeInfo.isVarPatternDeep(pat)) rhs
else makeFilter(rhs, pat1.duplicate, nme.CHECK_IF_REFUTABLE_STRING)
if (valeq) ValEq(pos, pat1, rhs1)
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
index 6cc957a9eb..6f3d7932a5 100644
--- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
@@ -173,9 +173,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
List(This(currentOwner)))
val extensionCall = atOwner(origMeth) {
localTyper.typedPos(rhs.pos) {
- (extensionCallPrefix /: vparamss) {
- case (fn, params) => Apply(fn, params map (param => Ident(param.symbol)))
- }
+ gen.mkForwarder(extensionCallPrefix, mmap(vparamss)(_.symbol))
}
}
deriveDefDef(tree)(_ => extensionCall)
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/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 38e55a3c01..8ad15f37e4 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -245,6 +245,68 @@ abstract class TreeInfo {
isSelfConstrCall(tree1) || isSuperConstrCall(tree1)
}
+ /**
+ * Does this tree represent an irrefutable pattern match
+ * in the position `for { <tree> <- expr }` based only
+ * on information at the `parser` phase? To qualify, there
+ * may be no subtree that will be interpreted as a
+ * Stable Identifier Pattern.
+ *
+ * For instance:
+ *
+ * {{{
+ * foo @ (bar, (baz, quux))
+ * }}}
+ *
+ * is a variable pattern; if the structure matches,
+ * then the remainder is inevitable.
+ *
+ * The following are not variable patterns.
+ *
+ * {{{
+ * foo @ (bar, (`baz`, quux)) // back quoted ident, not at top level
+ * foo @ (bar, Quux) // UpperCase ident, not at top level
+ * }}}
+ *
+ * If the pattern is a simple identifier, it is always
+ * a variable pattern. For example, the following
+ * introduce new bindings:
+ *
+ * {{{
+ * for { X <- xs } yield X
+ * for { `backquoted` <- xs } yield `backquoted`
+ * }}}
+ *
+ * Note that this differs from a case clause:
+ *
+ * {{{
+ * object X
+ * scrut match {
+ * case X => // case _ if scrut == X
+ * }
+ * }}}
+ *
+ * Background: [[https://groups.google.com/d/msg/scala-internals/qwa_XOw_7Ks/IktkeTBYqg0J]]
+ *
+ */
+ def isVarPatternDeep(tree: Tree): Boolean = {
+ def isVarPatternDeep0(tree: Tree): Boolean = {
+ tree match {
+ case Bind(name, pat) => isVarPatternDeep0(pat)
+ case Ident(name) => isVarPattern(tree)
+ case Apply(sel, args) =>
+ ( isReferenceToScalaMember(sel, TupleClass(args.size).name.toTermName)
+ && (args forall isVarPatternDeep0)
+ )
+ case _ => false
+ }
+ }
+ tree match {
+ case Ident(name) => true
+ case _ => isVarPatternDeep0(tree)
+ }
+ }
+
/** Is tree a variable pattern? */
def isVarPattern(pat: Tree): Boolean = pat match {
case x: Ident => !x.isBackquoted && nme.isVariableName(x.name)
@@ -330,24 +392,6 @@ abstract class TreeInfo {
case _ => false
}
- /** Is this tree comprised of nothing but identifiers,
- * but possibly in bindings or tuples? For instance
- *
- * foo @ (bar, (baz, quux))
- *
- * is a variable pattern; if the structure matches,
- * then the remainder is inevitable.
- */
- def isVariablePattern(tree: Tree): Boolean = tree match {
- case Bind(name, pat) => isVariablePattern(pat)
- case Ident(name) => true
- case Apply(sel, args) =>
- ( isReferenceToScalaMember(sel, TupleClass(args.size).name.toTermName)
- && (args forall isVariablePattern)
- )
- case _ => false
- }
-
/** Is this argument node of the form <expr> : _* ?
*/
def isWildcardStarArg(tree: Tree): Boolean = tree match {
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/t6644.scala b/test/files/run/t6644.scala
new file mode 100644
index 0000000000..b8b36f957c
--- /dev/null
+++ b/test/files/run/t6644.scala
@@ -0,0 +1,8 @@
+class Testable(val c: String) extends AnyVal {
+ def matching(cases: Boolean*) = cases contains true
+}
+
+object Test extends App {
+ assert(new Testable("").matching(true, false))
+}
+
diff --git a/test/files/run/t6646.check b/test/files/run/t6646.check
new file mode 100644
index 0000000000..b0b7ad32f3
--- /dev/null
+++ b/test/files/run/t6646.check
@@ -0,0 +1,5 @@
+Found NotNull
+Found lower
+Found 2
+A single ident is always a pattern
+A single ident is always a pattern
diff --git a/test/files/run/t6646.scala b/test/files/run/t6646.scala
new file mode 100644
index 0000000000..150b0df11e
--- /dev/null
+++ b/test/files/run/t6646.scala
@@ -0,0 +1,19 @@
+sealed trait ColumnOption
+case object NotNull extends ColumnOption
+case object PrimaryKey extends ColumnOption
+case object lower extends ColumnOption
+
+object Test {
+ def main(args: Array[String]) {
+ val l = List(PrimaryKey, NotNull, lower)
+
+ // withFilter must be generated in these
+ for (option @ NotNull <- l) println("Found " + option)
+ for (option @ `lower` <- l) println("Found " + option)
+ for ((`lower`, i) <- l.zipWithIndex) println("Found " + i)
+
+ // no withFilter
+ for (X <- List("A single ident is always a pattern")) println(X)
+ for (`x` <- List("A single ident is always a pattern")) println(`x`)
+ }
+}
diff --git a/tools/epfl-publish b/tools/epfl-publish
index de5e17b13f..cdf18823a5 100755
--- a/tools/epfl-publish
+++ b/tools/epfl-publish
@@ -24,7 +24,7 @@ if [[ -z $publish_to ]]; then
else
echo "Publishing nightly build to $publish_to"
# Archive Scala nightly distribution
- rsync -az dists/archives/ "$publish_to/distributions"
+ rsync -az --exclude scala-latest-sources.tgz dists/archives/ "$publish_to/distributions"
# only publish scaladoc nightly for trunk
[[ $version == "master" ]] && rsync -az build/scaladoc/ "$publish_to/docs"
# sbaz