aboutsummaryrefslogtreecommitdiff
path: root/tests/run/i659.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/i659.scala')
-rw-r--r--tests/run/i659.scala24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/run/i659.scala b/tests/run/i659.scala
index 5f10f15e8..d1229515d 100644
--- a/tests/run/i659.scala
+++ b/tests/run/i659.scala
@@ -1,12 +1,26 @@
class Foo(val a: Int) {
- //def foo = { {case x => x + a}: PartialFunction[Int, Int]}
+ def foo = { {case x => x + a}: PartialFunction[Int, Int]}
class Bar { def result(x: Int) = x + a }
def bar = new Bar
}
+class VFoo(val a: Int) extends AnyVal {
+ def foo = { {case x => x + a}: PartialFunction[Int, Int]}
+}
+
object Test extends dotty.runtime.LegacyApp {
- //val x = new Foo(1).foo.apply(2)
- val y = new Foo(1).bar.result(2)
- assert(y == 3, y)
- //assert(x == 3, x)
+
+ def Foo(a: Int) = {
+ class Bar { def result(x: Int) = x + a }
+ new Bar().result(2)
+ }
+
+ val x1 = new Foo(1).bar.result(2)
+ assert(x1 == 3, s"x1 = $x1")
+ val x2 = Foo(1)
+ assert(x2 == 3, s"x2 = $x2")
+ val x3 = new Foo(1).foo.apply(2)
+ assert(x3 == 3, s"x3 = $x3")
+ val x4 = new VFoo(1).foo.apply(2)
+ assert(x4 == 3, s"x4 = $x4")
}