summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala13
-rw-r--r--src/library/scala/util/parsing/combinator/Parsers.scala20
-rw-r--r--test/files/pos/t0905.scala6
-rw-r--r--test/files/run/t0911.scala9
4 files changed, 42 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index e971e4138d..216029b64f 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -446,11 +446,14 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
if (tree.symbol.isClassConstructor) {
atOwner(tree.symbol) {
val rhs1 = (rhs: @unchecked) match {
- case Block(stat :: stats, expr) =>
- copy.Block(
- rhs,
- withInConstructorFlag(INCONSTRUCTOR) { transform(stat) } :: transformTrees(stats),
- transform(expr));
+ case Block(stats, expr) =>
+ def transformInConstructor(stat: Tree) =
+ withInConstructorFlag(INCONSTRUCTOR) { transform(stat) }
+ val presupers = treeInfo.preSuperFields(stats) map transformInConstructor
+ val rest = stats drop presupers.length
+ val supercalls = rest take 1 map transformInConstructor
+ val others = rest drop 1 map transform
+ copy.Block(rhs, presupers ::: supercalls ::: others, transform(expr))
}
copy.DefDef(
tree, mods, name, transformTypeDefs(tparams),
diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala
index b6c30abe17..1061b85ac8 100644
--- a/src/library/scala/util/parsing/combinator/Parsers.scala
+++ b/src/library/scala/util/parsing/combinator/Parsers.scala
@@ -230,9 +230,27 @@ trait Parsers {
*/
def ~ [U](p: => Parser[U]): Parser[~[T, U]] = (for(a <- this; b <- p) yield new ~(a,b)).named("~")
+ /** A parser combinator for sequential composition which keeps only the right result
+ *
+ * <p> `p ~> q' succeeds if `p' succeeds and `q' succeeds on the input
+ * left over by `p'.</p>
+ *
+ * @param q a parser that will be executed after `p' (this parser) succeeds
+ * @return a `Parser' that -- on success -- returns the result of `q'.
+ */
def ~> [U](p: => Parser[U]): Parser[U] = (for(a <- this; b <- p) yield b).named("~>")
- def <~ [U](p: => Parser[U]): Parser[T] = (for(a <- this; b <- p) yield a).named("<~")
+ /** A parser combinator for sequential composition which keeps only the left result
+ *
+ * <p> `p &lt;~ q' succeeds if `p' succeeds and `q' succeeds on the input
+ * left over by `p'.</p>
+ *
+ * <b>Note:</b> &lt;~ has lower operator precedence than ~ or ~>.
+ *
+ * @param q a parser that will be executed after `p' (this parser) succeeds
+ * @return a `Parser' that -- on success -- returns the result of `p'.
+ */
+ def <~ [U](p: => Parser[U]): Parser[T] = (for(a <- this; b <- p) yield a).named("<~")
/* not really useful: V cannot be inferred because Parser is covariant in first type parameter (V is always trivially Nothing)
def ~~ [U, V](q: => Parser[U])(implicit combine: (T, U) => V): Parser[V] = new Parser[V] {
diff --git a/test/files/pos/t0905.scala b/test/files/pos/t0905.scala
new file mode 100644
index 0000000000..8cd84759cf
--- /dev/null
+++ b/test/files/pos/t0905.scala
@@ -0,0 +1,6 @@
+object Test {
+ trait A[T]
+ def f(implicit p: A[T] forSome { type T } ) = null
+ implicit val x: A[T] forSome { type T } = null
+ println(f)
+}
diff --git a/test/files/run/t0911.scala b/test/files/run/t0911.scala
new file mode 100644
index 0000000000..f4d93eb571
--- /dev/null
+++ b/test/files/run/t0911.scala
@@ -0,0 +1,9 @@
+class Foo(val bar : () => String);
+
+class IP extends {
+ val baz = "bar";
+} with Foo(() => baz);
+
+object Main extends Application{
+ (new IP).bar();
+}