Skip to content

Commit 1952b9c

Browse files
committed
more tests for SI-3761
1 parent 94e5d76 commit 1952b9c

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
t3761-overload-byname.scala:9: error: ambiguous reference to overloaded definition,
2+
both method m1 in object t of type (x: => Int, s: Object)Int
3+
and method m1 in object t of type (x: => AnyVal, s: String)Int
4+
match argument types (Int,String)
5+
m1(1, "")
6+
^
7+
t3761-overload-byname.scala:11: error: ambiguous reference to overloaded definition,
8+
both method m2 in object t of type (x: => Int, s: Object)Int
9+
and method m2 in object t of type (x: => Any, s: String)Int
10+
match argument types (Int,String)
11+
m2(1, "")
12+
^
13+
two errors found
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
object t {
2+
def m1(x: => AnyVal, s: String) = 0
3+
def m1(x: => Int, s: Object) = 1
4+
5+
def m2(x: => Any, s: String) = 0
6+
def m2(x: => Int, s: Object) = 1
7+
8+
9+
m1(1, "")
10+
m1(1d, "")
11+
m2(1, "")
12+
m2("", "")
13+
}

test/files/run/t3761-overload-byname.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ goodnight!
44
goodnight moon, nobody, noises everywhere
55
0
66
1
7+
0
8+
1
9+
0
10+
1
11+
0
12+
1

test/files/run/t3761-overload-byname.scala

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,18 @@ class OverTheTop {
88
def info1(m: =>String, args: Any*) = m +" "+ args.mkString(", ")
99

1010
// @lrytz
11-
def m[A](x: => Int) = 0; def m[A](x: => Int, xs: Int*) = 1
11+
def m[A](x: => Int) = 0; def m[A](x: => Int, xs: Int*) = 1
12+
13+
def m1(x: => Int, s: String) = 0
14+
def m1(x: => Int, s: Object) = 1
15+
16+
def m2(x: => Int, s: String) = 0
17+
def m2(x: => AnyVal, s: Object) = 1
18+
19+
def m3(x: => Int, s: String) = 0
20+
def m3(x: => Any, s: Object) = 1
1221
}
22+
1323
object Test {
1424
def main(args: Array[String]) {
1525
val top = new OverTheTop
@@ -19,5 +29,11 @@ object Test {
1929
println(top.info1("goodnight", "moon", "nobody", "noises everywhere"))
2030
println(top.m(17))
2131
println(top.m(17,19))
32+
println(top.m1(1, "two"))
33+
println(top.m1(1, new Object()))
34+
println(top.m2(1, ""))
35+
println(top.m2(1d, ""))
36+
println(top.m3(1, ""))
37+
println(top.m3("", ""))
2238
}
2339
}

0 commit comments

Comments
 (0)