Skip to content

Commit

Permalink
more tests for SI-3761
Browse files Browse the repository at this point in the history
  • Loading branch information
lrytz committed May 23, 2012
1 parent 94e5d76 commit 1952b9c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
13 changes: 13 additions & 0 deletions test/files/neg/t3761-overload-byname.check
@@ -0,0 +1,13 @@
t3761-overload-byname.scala:9: error: ambiguous reference to overloaded definition,
both method m1 in object t of type (x: => Int, s: Object)Int
and method m1 in object t of type (x: => AnyVal, s: String)Int
match argument types (Int,String)
m1(1, "")
^
t3761-overload-byname.scala:11: error: ambiguous reference to overloaded definition,
both method m2 in object t of type (x: => Int, s: Object)Int
and method m2 in object t of type (x: => Any, s: String)Int
match argument types (Int,String)
m2(1, "")
^
two errors found
13 changes: 13 additions & 0 deletions test/files/neg/t3761-overload-byname.scala
@@ -0,0 +1,13 @@
object t {
def m1(x: => AnyVal, s: String) = 0
def m1(x: => Int, s: Object) = 1

def m2(x: => Any, s: String) = 0
def m2(x: => Int, s: Object) = 1


m1(1, "")
m1(1d, "")
m2(1, "")
m2("", "")
}
6 changes: 6 additions & 0 deletions test/files/run/t3761-overload-byname.check
Expand Up @@ -4,3 +4,9 @@ goodnight!
goodnight moon, nobody, noises everywhere goodnight moon, nobody, noises everywhere
0 0
1 1
0
1
0
1
0
1
18 changes: 17 additions & 1 deletion test/files/run/t3761-overload-byname.scala
Expand Up @@ -8,8 +8,18 @@ class OverTheTop {
def info1(m: =>String, args: Any*) = m +" "+ args.mkString(", ") def info1(m: =>String, args: Any*) = m +" "+ args.mkString(", ")


// @lrytz // @lrytz
def m[A](x: => Int) = 0; def m[A](x: => Int, xs: Int*) = 1 def m[A](x: => Int) = 0; def m[A](x: => Int, xs: Int*) = 1

def m1(x: => Int, s: String) = 0
def m1(x: => Int, s: Object) = 1

def m2(x: => Int, s: String) = 0
def m2(x: => AnyVal, s: Object) = 1

def m3(x: => Int, s: String) = 0
def m3(x: => Any, s: Object) = 1
} }

object Test { object Test {
def main(args: Array[String]) { def main(args: Array[String]) {
val top = new OverTheTop val top = new OverTheTop
Expand All @@ -19,5 +29,11 @@ object Test {
println(top.info1("goodnight", "moon", "nobody", "noises everywhere")) println(top.info1("goodnight", "moon", "nobody", "noises everywhere"))
println(top.m(17)) println(top.m(17))
println(top.m(17,19)) println(top.m(17,19))
println(top.m1(1, "two"))
println(top.m1(1, new Object()))
println(top.m2(1, ""))
println(top.m2(1d, ""))
println(top.m3(1, ""))
println(top.m3("", ""))
} }
} }

0 comments on commit 1952b9c

Please sign in to comment.