summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/disabled/run/syncchannel.check (renamed from test/files/run/syncchannel.check)0
-rw-r--r--test/disabled/run/syncchannel.scala (renamed from test/files/run/syncchannel.scala)0
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala156
-rw-r--r--test/files/jvm/try-type-tests.scala250
-rw-r--r--test/files/neg/exhausting.check2
-rw-r--r--test/files/neg/t4691_exhaust_extractor.check13
-rw-r--r--test/files/neg/t4691_exhaust_extractor.flags1
-rw-r--r--test/files/neg/t4691_exhaust_extractor.scala33
-rw-r--r--test/files/neg/t5589neg.check4
-rw-r--r--test/files/pos/t6008.flags1
-rw-r--r--test/files/pos/t6008.scala12
-rw-r--r--test/files/run/reflection-equality.check53
-rw-r--r--test/files/run/reflection-equality.scala22
-rw-r--r--test/files/run/t5009.check1
-rw-r--r--test/files/run/t5009.scala7
-rw-r--r--test/files/run/t5907.check31
-rw-r--r--test/files/run/t5907.scala118
17 files changed, 618 insertions, 86 deletions
diff --git a/test/files/run/syncchannel.check b/test/disabled/run/syncchannel.check
index d81cc0710e..d81cc0710e 100644
--- a/test/files/run/syncchannel.check
+++ b/test/disabled/run/syncchannel.check
diff --git a/test/files/run/syncchannel.scala b/test/disabled/run/syncchannel.scala
index 66ae47fd0a..66ae47fd0a 100644
--- a/test/files/run/syncchannel.scala
+++ b/test/disabled/run/syncchannel.scala
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala
index 012460147a..407027f904 100644
--- a/test/files/jvm/scala-concurrent-tck.scala
+++ b/test/files/jvm/scala-concurrent-tck.scala
@@ -138,7 +138,7 @@ trait FutureCallbacks extends TestBase {
testOnSuccessWhenFailed()
testOnFailure()
testOnFailureWhenSpecialThrowable(5, new Error)
- testOnFailureWhenSpecialThrowable(6, new scala.util.control.ControlThrowable { })
+ // testOnFailureWhenSpecialThrowable(6, new scala.util.control.ControlThrowable { })
//TODO: this test is currently problematic, because NonFatal does not match InterruptedException
//testOnFailureWhenSpecialThrowable(7, new InterruptedException)
testOnFailureWhenTimeoutException()
@@ -599,10 +599,10 @@ trait FutureProjections extends TestBase {
throw cause
}
f.failed onComplete {
- case Success(t) =>
+ case Right(t) =>
assert(t == cause)
done()
- case Failure(t) =>
+ case Left(t) =>
assert(false)
}
}
@@ -624,9 +624,9 @@ trait FutureProjections extends TestBase {
done =>
val f = future { 0 }
f.failed onComplete {
- case Success(t) =>
+ case Right(t) =>
assert(false)
- case Failure(t) =>
+ case Left(t) =>
assert(t.isInstanceOf[NoSuchElementException])
done()
}
@@ -733,80 +733,80 @@ trait Exceptions extends TestBase {
}
-trait TryEitherExtractor extends TestBase {
-
- import scala.util.{Try, Success, Failure}
-
- def testSuccessMatch(): Unit = once {
- done =>
- val thisIsASuccess = Success(42)
- thisIsASuccess match {
- case Success(v) =>
- done()
- assert(v == 42)
- case Failure(e) =>
- done()
- assert(false)
- case other =>
- done()
- assert(false)
- }
- }
-
- def testRightMatch(): Unit = once {
- done =>
- val thisIsNotASuccess: Right[Throwable, Int] = Right(43)
- thisIsNotASuccess match {
- case Success(v) =>
- done()
- assert(v == 43)
- case Failure(e) =>
- done()
- assert(false)
- case other =>
- done()
- assert(false)
- }
- }
-
- def testFailureMatch(): Unit = once {
- done =>
- val thisIsAFailure = Failure(new Exception("I'm an exception"))
- thisIsAFailure match {
- case Success(v) =>
- done()
- assert(false)
- case Failure(e) =>
- done()
- assert(e.getMessage == "I'm an exception")
- case other =>
- done()
- assert(false)
- }
- }
-
- def testLeftMatch(): Unit = once {
- done =>
- val thisIsNotAFailure: Left[Throwable, Int] = Left(new Exception("I'm an exception"))
- thisIsNotAFailure match {
- case Success(v) =>
- done()
- assert(false)
- case Failure(e) =>
- done()
- assert(e.getMessage == "I'm an exception")
- case other =>
- done()
- assert(false)
- }
+// trait TryEitherExtractor extends TestBase {
+
+// import scala.util.{Try, Success, Failure}
+
+// def testSuccessMatch(): Unit = once {
+// done =>
+// val thisIsASuccess = Success(42)
+// thisIsASuccess match {
+// case Success(v) =>
+// done()
+// assert(v == 42)
+// case Failure(e) =>
+// done()
+// assert(false)
+// case other =>
+// done()
+// assert(false)
+// }
+// }
+
+// def testRightMatch(): Unit = once {
+// done =>
+// val thisIsNotASuccess: Right[Throwable, Int] = Right(43)
+// thisIsNotASuccess match {
+// case Success(v) =>
+// done()
+// assert(v == 43)
+// case Failure(e) =>
+// done()
+// assert(false)
+// case other =>
+// done()
+// assert(false)
+// }
+// }
+
+// def testFailureMatch(): Unit = once {
+// done =>
+// val thisIsAFailure = Failure(new Exception("I'm an exception"))
+// thisIsAFailure match {
+// case Success(v) =>
+// done()
+// assert(false)
+// case Failure(e) =>
+// done()
+// assert(e.getMessage == "I'm an exception")
+// case other =>
+// done()
+// assert(false)
+// }
+// }
+
+// def testLeftMatch(): Unit = once {
+// done =>
+// val thisIsNotAFailure: Left[Throwable, Int] = Left(new Exception("I'm an exception"))
+// thisIsNotAFailure match {
+// case Success(v) =>
+// done()
+// assert(false)
+// case Failure(e) =>
+// done()
+// assert(e.getMessage == "I'm an exception")
+// case other =>
+// done()
+// assert(false)
+// }
- }
+// }
- testSuccessMatch()
- testRightMatch()
- testFailureMatch()
- testLeftMatch()
-}
+// testSuccessMatch()
+// testRightMatch()
+// testFailureMatch()
+// testLeftMatch()
+// }
trait CustomExecutionContext extends TestBase {
import scala.concurrent.{ ExecutionContext, Awaitable }
@@ -935,7 +935,7 @@ with FutureCombinators
with FutureProjections
with Promises
with Exceptions
-with TryEitherExtractor
+// with TryEitherExtractor
with CustomExecutionContext
{
System.exit(0)
diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala
new file mode 100644
index 0000000000..eecbb0ae57
--- /dev/null
+++ b/test/files/jvm/try-type-tests.scala
@@ -0,0 +1,250 @@
+import scala.util.{Try, Success, Failure}
+
+// tests the basic combinators on Try
+trait TryStandard {
+
+ def testForeachSuccess(): Unit = {
+ val t = Success(1)
+ var res = 0
+ t.foreach(x => res = x * 10)
+ assert(res == 10)
+ }
+
+ def testForeachFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ t.foreach(x => assert(false))
+ }
+
+ def testFlatMapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.flatMap(x => Try(x * 10))
+ assert(n.get == 10)
+ }
+
+ def testFlatMapFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.flatMap{ x => assert(false); Try() }
+ }
+
+ def testMapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.map(x => x * 10)
+ assert(n.get == 10)
+ }
+
+ def testMapFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.map(x => assert(false))
+ }
+
+ def testFilterSuccessTrue(): Unit = {
+ val t = Success(1)
+ val n = t.filter(x => x > 0)
+ assert(n.get == 1)
+ }
+
+ def testFilterSuccessFalse(): Unit = {
+ val t = Success(1)
+ val n = t.filter(x => x < 0)
+ n match {
+ case Success(v) => assert(false)
+ case Failure(e: NoSuchElementException) => assert(true)
+ }
+ }
+
+ def testFilterFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.filter{ x => assert(false); true }
+ }
+
+ def testRescueSuccess(): Unit = {
+ val t = Success(1)
+ t.rescue{ case x => assert(false); Try() }
+ }
+
+ def testRescueFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.rescue{ case x => Try(1) }
+ assert(n.get == 1)
+ }
+
+ def testRecoverSuccess(): Unit = {
+ val t = Success(1)
+ t.recover{ case x => assert(false); 99 }
+ }
+
+ def testRecoverFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.recover{ case x => 1 }
+ assert(n.get == 1)
+ }
+
+ def testFlattenSuccess(): Unit = {
+ val f = Failure(new Exception("foo"))
+ val t = Success(f)
+ assert(t.flatten == f)
+ }
+
+ def testFailedSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.failed
+ n match {
+ case Failure(e: UnsupportedOperationException) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testFailedFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.failed
+ n match {
+ case Success(e: Exception) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ testForeachSuccess()
+ testForeachFailure()
+ testFlatMapSuccess()
+ testFlatMapFailure()
+ testMapSuccess()
+ testMapFailure()
+ testFilterSuccessTrue()
+ testFilterSuccessFalse()
+ testFilterFailure()
+ testRescueSuccess()
+ testRescueFailure()
+ testRecoverSuccess()
+ testRecoverFailure()
+ testFlattenSuccess()
+ testFailedSuccess()
+ testFailedFailure()
+}
+
+// tests that implicit conversions from Try to Either behave as expected
+trait TryImplicitConversionTry2Either {
+
+ def testTry2RightMap(): Unit = {
+ val t = Success(1)
+ val n = t.right.map(x => x * 100)
+ assert(n == Right(100))
+ }
+
+ def testTry2LeftMap(): Unit = {
+ val e = new Exception("foo")
+ val t = Failure(e)
+ val n = t.left.map(x => x)
+ assert(n == Left(e))
+ }
+
+ def testTry2FoldSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.fold(x => assert(false), y => y * 200)
+ assert(n == 200)
+ }
+
+ def testTry2FoldFailure(): Unit = {
+ val e = new Exception("foo")
+ val t = Failure(e)
+ val n = t.fold(x => x, y => assert(false))
+ assert(n == e)
+ }
+
+ def testTry2SwapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.swap
+ assert(n == Left(1))
+ }
+
+ def testTry2SwapFailure(): Unit = {
+ val e = new Exception("foo")
+ val t = Failure(e)
+ val n = t.swap
+ assert(n == Right(e))
+ }
+
+ // def testTry2MergeSucccess(): Unit = {
+ // val t: Try[Int] = Success(1)
+ // val n = (t: Either[Any, Any]).t.merge // connecting two implicit conversions
+ // assert(n == 1)
+ // }
+
+ // def testTry2MergeFailure(): Unit = {
+ // val e = new Exception("foo")
+ // val t = Failure(e)
+ // val n = (t: Either[Any, Any]).merge // connecting two implicit conversions
+ // assert(n == e)
+ // }
+
+ testTry2RightMap()
+ testTry2LeftMap()
+ testTry2FoldSuccess()
+ testTry2FoldFailure()
+ testTry2SwapSuccess()
+ testTry2SwapFailure()
+ // testTry2MergeSucccess()
+ // testTry2MergeFailure()
+}
+
+// tests that implicit conversions from Either to Try behave as expected
+trait TryImplicitConversionEither2Try {
+
+ def testRight2FilterSuccessTrue(): Unit = {
+ def expectsTry[U <% Try[Int]](rght: U): Try[Int] = {
+ val n = rght.filter(x => x > 0) // this should be converted to a Try
+ n
+ }
+ val r = Right(1)
+ val n = expectsTry(r)
+ assert(n == Success(1))
+ }
+
+ def testRight2FilterSuccessFalse(): Unit = {
+ def expectsTry[U <% Try[Int]](rght: U): Try[Int] = {
+ val n = rght.filter(x => x < 0) // this should be converted to a Try
+ n
+ }
+ val r = Right(1)
+ val n = expectsTry(r)
+ n match {
+ case Failure(e: NoSuchElementException) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testLeft2FilterFailure(): Unit = {
+ def expectsTry[U <% Try[Int]](rght: U): Try[Int] = {
+ val n = rght.filter(x => x > 0) // this should be converted to a Try
+ n
+ }
+ val r = Left(new Exception("foo"))
+ val n = expectsTry(r)
+ n match {
+ case Failure(e: Exception) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testRight2GetSuccess(): Unit = {
+ def expectsTry[U <% Try[Int]](rght: U): Int = {
+ val n = rght.get // this should be converted to a Try
+ n
+ }
+ val r = Right(1)
+ val n = expectsTry(r)
+ assert(n == 1)
+ }
+
+ testRight2FilterSuccessTrue()
+ testRight2FilterSuccessFalse()
+ testLeft2FilterFailure()
+ testRight2GetSuccess()
+}
+
+object Test
+extends App
+with TryStandard
+with TryImplicitConversionTry2Either
+with TryImplicitConversionEither2Try {
+ System.exit(0)
+} \ No newline at end of file
diff --git a/test/files/neg/exhausting.check b/test/files/neg/exhausting.check
index 7140b99428..0f0d13cb33 100644
--- a/test/files/neg/exhausting.check
+++ b/test/files/neg/exhausting.check
@@ -7,7 +7,7 @@ It would fail on the following input: Nil
def fail2[T](xs: List[T]) = xs match {
^
exhausting.scala:32: error: match may not be exhaustive.
-It would fail on the following input: List(<not in (1, 2)>)
+It would fail on the following input: List((x: Int forSome x not in (1, 2)))
def fail3a(xs: List[Int]) = xs match {
^
exhausting.scala:39: error: match may not be exhaustive.
diff --git a/test/files/neg/t4691_exhaust_extractor.check b/test/files/neg/t4691_exhaust_extractor.check
new file mode 100644
index 0000000000..cd12e56f86
--- /dev/null
+++ b/test/files/neg/t4691_exhaust_extractor.check
@@ -0,0 +1,13 @@
+t4691_exhaust_extractor.scala:17: error: match may not be exhaustive.
+It would fail on the following input: Bar3()
+ def f1(x: Foo) = x match {
+ ^
+t4691_exhaust_extractor.scala:23: error: match may not be exhaustive.
+It would fail on the following input: Bar3()
+ def f2(x: Foo) = x match {
+ ^
+t4691_exhaust_extractor.scala:29: error: match may not be exhaustive.
+It would fail on the following input: Bar3()
+ def f3(x: Foo) = x match {
+ ^
+three errors found
diff --git a/test/files/neg/t4691_exhaust_extractor.flags b/test/files/neg/t4691_exhaust_extractor.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/t4691_exhaust_extractor.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t4691_exhaust_extractor.scala b/test/files/neg/t4691_exhaust_extractor.scala
new file mode 100644
index 0000000000..c68c33d654
--- /dev/null
+++ b/test/files/neg/t4691_exhaust_extractor.scala
@@ -0,0 +1,33 @@
+sealed trait Foo
+class Bar1 extends Foo
+class Bar2 extends Foo
+class Bar3 extends Foo
+
+// these extractors are known to always succeed as they return a Some
+object Baz1 {
+ def unapply(x: Bar1): Some[Int] = Some(1)
+}
+object Baz2 {
+ def unapply(x: Bar2): Some[Int] = Some(2)
+}
+
+
+object Test {
+ // warning: missing Bar3
+ def f1(x: Foo) = x match {
+ case _: Bar1 => 1
+ case _: Bar2 => 2
+ }
+
+ // warning: missing Bar3
+ def f2(x: Foo) = x match {
+ case _: Bar1 => 1
+ case Baz2(x) => x
+ }
+
+ // warning: missing Bar3
+ def f3(x: Foo) = x match {
+ case Baz1(x) => x
+ case Baz2(x) => x
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/t5589neg.check b/test/files/neg/t5589neg.check
index b3ff16d7e4..f1dad94df3 100644
--- a/test/files/neg/t5589neg.check
+++ b/test/files/neg/t5589neg.check
@@ -1,4 +1,4 @@
-t5589neg.scala:2: warning: `withFilter' method does not yet exist on Either.RightProjection[Int,String], using `filter' method instead
+t5589neg.scala:2: warning: `withFilter' method does not yet exist on scala.util.Either.RightProjection[Int,String], using `filter' method instead
def f5(x: Either[Int, String]) = for ((y1, y2: String) <- x.right) yield ((y1, y2))
^
t5589neg.scala:2: error: constructor cannot be instantiated to expected type;
@@ -6,7 +6,7 @@ t5589neg.scala:2: error: constructor cannot be instantiated to expected type;
required: String
def f5(x: Either[Int, String]) = for ((y1, y2: String) <- x.right) yield ((y1, y2))
^
-t5589neg.scala:3: warning: `withFilter' method does not yet exist on Either.RightProjection[Int,String], using `filter' method instead
+t5589neg.scala:3: warning: `withFilter' method does not yet exist on scala.util.Either.RightProjection[Int,String], using `filter' method instead
def f6(x: Either[Int, String]) = for ((y1, y2: Any) <- x.right) yield ((y1, y2))
^
t5589neg.scala:3: error: constructor cannot be instantiated to expected type;
diff --git a/test/files/pos/t6008.flags b/test/files/pos/t6008.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/pos/t6008.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t6008.scala b/test/files/pos/t6008.scala
new file mode 100644
index 0000000000..84ae19b211
--- /dev/null
+++ b/test/files/pos/t6008.scala
@@ -0,0 +1,12 @@
+// none of these should complain about exhaustivity
+class Test {
+ // It would fail on the following inputs: (_, false), (_, true)
+ def x(in: (Int, Boolean)) = in match { case (i: Int, b: Boolean) => 3 }
+
+ // There is no warning if the Int is ignored or bound without an explicit type:
+ def y(in: (Int, Boolean)) = in match { case (_, b: Boolean) => 3 }
+
+ // Keeping the explicit type for the Int but dropping the one for Boolean presents a spurious warning again:
+ // It would fail on the following input: (_, _)
+ def z(in: (Int, Boolean)) = in match { case (i: Int, b) => 3 }
+} \ No newline at end of file
diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check
new file mode 100644
index 0000000000..feafb58d3b
--- /dev/null
+++ b/test/files/run/reflection-equality.check
@@ -0,0 +1,53 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> class X {
+ def methodIntIntInt(x: Int, y: Int) = x+y
+}
+defined class X
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.reflect.runtime.{ currentMirror => cm }
+import scala.reflect.runtime.{currentMirror=>cm}
+
+scala> def im: InstanceMirror = cm.reflect(new X)
+im: reflect.runtime.universe.InstanceMirror
+
+scala> val cs: ClassSymbol = im.symbol
+cs: reflect.runtime.universe.ClassSymbol = class X
+
+scala> val ts: Type = cs.typeSignature
+ts: reflect.runtime.universe.Type =
+java.lang.Object {
+ def <init>: <?>
+ def methodIntIntInt: <?>
+}
+
+scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethodSymbol
+ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt
+
+scala> val MethodType( _, t1 ) = ms.typeSignature
+t1: reflect.runtime.universe.Type = scala.Int
+
+scala> val t2 = typeOf[scala.Int]
+t2: reflect.runtime.universe.Type = Int
+
+scala> t1 == t2
+res0: Boolean = false
+
+scala> t1 =:= t2
+res1: Boolean = true
+
+scala> t1 <:< t2
+res2: Boolean = true
+
+scala> t2 <:< t1
+res3: Boolean = true
+
+scala>
diff --git a/test/files/run/reflection-equality.scala b/test/files/run/reflection-equality.scala
new file mode 100644
index 0000000000..35dc47a59f
--- /dev/null
+++ b/test/files/run/reflection-equality.scala
@@ -0,0 +1,22 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+ |class X {
+ | def methodIntIntInt(x: Int, y: Int) = x+y
+ |}
+ |
+ |import scala.reflect.runtime.universe._
+ |import scala.reflect.runtime.{ currentMirror => cm }
+ |def im: InstanceMirror = cm.reflect(new X)
+ |val cs: ClassSymbol = im.symbol
+ |val ts: Type = cs.typeSignature
+ |val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethodSymbol
+ |val MethodType( _, t1 ) = ms.typeSignature
+ |val t2 = typeOf[scala.Int]
+ |t1 == t2
+ |t1 =:= t2
+ |t1 <:< t2
+ |t2 <:< t1
+ |""".stripMargin
+}
diff --git a/test/files/run/t5009.check b/test/files/run/t5009.check
index cc9df54b34..6c567227b5 100644
--- a/test/files/run/t5009.check
+++ b/test/files/run/t5009.check
@@ -1,4 +1,5 @@
C(1,true)
10
C(7283,20)
+C(66,-3)
100
diff --git a/test/files/run/t5009.scala b/test/files/run/t5009.scala
index b4fe1bc894..db12c0d685 100644
--- a/test/files/run/t5009.scala
+++ b/test/files/run/t5009.scala
@@ -6,12 +6,9 @@ object Test extends App {
println(c)
println(c.l)
- val f1a = c.copy(y = 20, x = 7283)
+ println(c.copy(y = 20, x = 7283)("enwa", b = false)(l = -1, s = new Object))
- val f1b = c.copy[Int, String, Object](y = 20, x = 7283)
- val f2b = f1b("lkdjen", false)
- val res = f2b(new Object, 100)
+ val res = c.copy[Int, String, Object](y = -3, x = 66)("lkdjen", false)(new Object, 100)
println(res)
println(res.l)
-
}
diff --git a/test/files/run/t5907.check b/test/files/run/t5907.check
new file mode 100644
index 0000000000..bc23692679
--- /dev/null
+++ b/test/files/run/t5907.check
@@ -0,0 +1,31 @@
+c1: 2
+c1: 2873
+c2: 37
+c3: 1, 2, 27
+c3: 1, 22, 27
+c3: 11, 7, 27
+c4: 1
+c4: 23
+c5: 1, 2, 33, b
+c5: 1, 19, 33, b
+c5: 1, 2, 193, c
+c5: 1, 371, 193, c
+c5: -1, 2, -2, lken
+c6: 29, 18, -12
+c6: 1, 93, 2892
+c6: 1, 93, 761
+c7: 1, 22, 33, elkj
+c7: 1, 283, 29872, me
+c7: 37, 298, 899, ekjr
+c8: 172, 989, 77, eliurna
+c8: 1, 82, 2111, schtring
+c8: -1, 92, 29, lken
+c9: 1, 271, ehebab
+c9: 1, 299, enag
+c9: 1, 299, enag
+c9: 1, 299, enag
+c9: -42, 99, flae
+c9: 10, 298, 27
+c9: elkn, en, emn
+c9: ka, kb, kb
+c9: ka, kb, ka
diff --git a/test/files/run/t5907.scala b/test/files/run/t5907.scala
new file mode 100644
index 0000000000..a005e9fbd3
--- /dev/null
+++ b/test/files/run/t5907.scala
@@ -0,0 +1,118 @@
+object Test extends App {
+ t
+
+ def t {
+ val c1 = C1()(1)
+ println(c1.copy()(2))
+
+ {
+ implicit val i = 2873
+ println(c1.copy())
+ }
+
+ val c2 = C2()(1)
+ println(c2.copy()(37))
+
+ val c3 = C3(1,2)(3)
+ println(c3.copy()(27))
+ println(c3.copy(y = 22)(27))
+ println(c3.copy(y = 7, x = 11)(27))
+
+ val c4 = C4(1)
+ println(c4.copy())
+ println(c4.copy(x = 23))
+
+ val c5 = C5(1,2)(3,"a")
+ println(c5.copy()(33,"b"))
+ println(c5.copy(y = 19)(33,"b"))
+
+ {
+ implicit val i = 193
+ implicit val s = "c"
+ println(c5.copy())
+ println(c5.copy(y = 371))
+ println(c5.copy(x = -1)(-2, "lken"))
+ }
+
+ val c6 = C6(1)(2)(3)
+ println(c6.copy(29)(18)(-12))
+
+ {
+ implicit val i = 2892
+ println(c6.copy(x = 1)(93))
+ println(c6.copy(x = 1)(93)(761))
+ }
+
+ val c7 = C7(1)(2)(3)("h")
+ println(c7.copy()(22)(33)("elkj"))
+
+ {
+ implicit val s = "me"
+ println(c7.copy()(283)(29872))
+ println(c7.copy(37)(298)(899)("ekjr"))
+ }
+
+ val c8 = C8(1)(2,3)()("els")
+ println(c8.copy(x = 172)(989, 77)()("eliurna"))
+
+ {
+ implicit val s = "schtring"
+ println(c8.copy()(82,2111)())
+ println(c8.copy(x = -1)(92,29)()("lken"))
+ }
+
+ val c9 = C9(1)(2)()()("u")
+ println(c9.copy()(271)()()("ehebab"))
+
+ {
+ implicit val s = "enag"
+ println(c9.copy()(299))
+ println(c9.copy()(299)())
+ println(c9.copy()(299)()())
+ println(c9.copy(x = -42)(99)()()("flae"))
+ }
+
+ class KA { override def toString = "ka" }
+ class KB extends KA { override def toString = "kb" }
+ val c10 = C10(10)(3)(19)
+ println(c10.copy()(298)(27))
+ println(c10.copy("elkn")("en")("emn"))
+ println(c10.copy(new KA)(new KB)(new KB))
+
+ {
+ implicit val k = new KA
+ println(c10.copy(new KA)(new KB))
+ }
+ }
+}
+
+case class C1(implicit x: Int) {
+ override def toString = s"c1: $x"
+}
+case class C2()(y: Int) {
+ override def toString = s"c2: $y"
+}
+case class C3(x: Int, y: Int)(z: Int) {
+ override def toString = s"c3: $x, $y, $z"
+}
+case class C4(x: Int) {
+ override def toString = s"c4: $x"
+}
+case class C5(x: Int, y: Int)(implicit z: Int, s: String) {
+ override def toString = s"c5: $x, $y, $z, $s"
+}
+case class C6(x: Int)(y: Int)(implicit z: Int) {
+ override def toString = s"c6: $x, $y, $z"
+}
+case class C7(x: Int)(y: Int)(z: Int)(implicit s: String) {
+ override def toString = s"c7: $x, $y, $z, $s"
+}
+case class C8(x: Int)(y: Int, z: Int)()(implicit s: String) {
+ override def toString = s"c8: $x, $y, $z, $s"
+}
+case class C9(x: Int)(y: Int)()()(implicit s: String) {
+ override def toString = s"c9: $x, $y, $s"
+}
+case class C10[T,U <: T](x: T)(y: U)(implicit z: T) {
+ override def toString = s"c9: $x, $y, $z"
+}