diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/names-defaults-neg-ref.check | 16 | ||||
-rw-r--r-- | test/files/neg/names-defaults-neg-ref.scala | 26 | ||||
-rw-r--r-- | test/files/neg/names-defaults-neg.check | 11 | ||||
-rw-r--r-- | test/files/neg/names-defaults-neg.scala | 6 | ||||
-rw-r--r-- | test/files/run/names-defaults.scala | 7 |
5 files changed, 50 insertions, 16 deletions
diff --git a/test/files/neg/names-defaults-neg-ref.check b/test/files/neg/names-defaults-neg-ref.check new file mode 100644 index 0000000000..ac37816762 --- /dev/null +++ b/test/files/neg/names-defaults-neg-ref.check @@ -0,0 +1,16 @@ +names-defaults-neg-ref.scala:3: error: in anonymous class $anon, multiple overloaded alternatives of method f define default arguments. +The members with defaults are defined in trait B2235 and trait A2235. + new A2235 with B2235 + ^ +names-defaults-neg-ref.scala:7: error: in class A, multiple overloaded alternatives of method foo define default arguments() +class A { + ^ +names-defaults-neg-ref.scala:17: error: in class C, multiple overloaded alternatives of method bar define default arguments. +The members with defaults are defined in class C and class B. +class C extends B { + ^ +names-defaults-neg-ref.scala:21: error: overriding method bar$default$1 in class B of type => String; + method bar$default$1 has incompatible type + def bar(i: Int = 129083) = i + ^ +four errors found diff --git a/test/files/neg/names-defaults-neg-ref.scala b/test/files/neg/names-defaults-neg-ref.scala new file mode 100644 index 0000000000..4611aadd22 --- /dev/null +++ b/test/files/neg/names-defaults-neg-ref.scala @@ -0,0 +1,26 @@ +object Test extends Application { + // #2235 + new A2235 with B2235 +} + +// only one overloaded alternative is allowed to have defaults +class A { + def foo(a: Int = 0) = a + def foo(b: String = "another") = b +} + +class B { + def foo(a: Int) = a + def bar(u: String = "ldksj") = u +} + +class C extends B { + override def foo(a: Int = 1092) = a + def foo(b: String = "lskdfj") + + def bar(i: Int = 129083) = i +} + +// #2235 +trait A2235 { def f(x: Int = 1) = x } +trait B2235 { def f(x: String = "1") = x } diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index d8eb03fbaf..057a0519d7 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -104,13 +104,4 @@ names-defaults-neg.scala:83: error: type mismatch; Error occured in an application involving default arguments. new A2[String]() ^ -names-defaults-neg.scala:95: error: multiple overloaded alternatives of method foo define default arguments - def foo(a: Int = 0) = a - ^ -names-defaults-neg.scala:105: error: multiple overloaded alternatives of method foo define default arguments - override def foo(a: Int = 1092) = a - ^ -names-defaults-neg.scala:108: error: multiple overloaded alternatives of method bar define default arguments - def bar(i: Int = 129083) = i - ^ -28 errors found +25 errors found diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala index cf149d4b31..5829da361c 100644 --- a/test/files/neg/names-defaults-neg.scala +++ b/test/files/neg/names-defaults-neg.scala @@ -90,12 +90,6 @@ object Test extends Application { def test8[T](x: => T) = println("test8") } -// only one overloaded alternative is allowed to have defaults -class A { - def foo(a: Int = 0) = a - def foo(b: String = "another") = b -} - class B { def foo(a: Int) = a def bar(u: String = "ldksj") = u diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 8e8c8a1e4a..05f0afa199 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -251,6 +251,13 @@ object Test extends Application { // (cannot call f using the default, List(1,2) doesn't match the param type) + // #2290 + def spawn(a: Int, b: => Unit) = { () } + def t { + spawn(b = { val ttt = 1; ttt }, a = 0) + } + + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v)) |