diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-02-21 22:39:58 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-02-22 09:44:39 +0100 |
commit | 17a3639adb5969e8381fd08655cc6fb2aea19c24 (patch) | |
tree | 5f8ba8ccbb26753bc89c819a5abac58ebd527a47 | |
parent | 00624a39ed84c3fd245dd9df7454d4cec4399e13 (diff) | |
download | scala-17a3639adb5969e8381fd08655cc6fb2aea19c24.tar.gz scala-17a3639adb5969e8381fd08655cc6fb2aea19c24.tar.bz2 scala-17a3639adb5969e8381fd08655cc6fb2aea19c24.zip |
SI-8197 Only consider immediate params for defaults, overloading
A recent commit fixed the behaviour of overloading with regards
to discarding candiates that include default arguments. The old
check was checking the wrong flag.
But, the new code is actually checking all parameter lists for
defaults, which led to a regression in scala-io, which is distilled
in the enclosed test case. Applications are typechecked one
parameter list at a time, so a holistic check for defaults doesn't
seem to make sense; only defaults in the first parameter list
ought to count.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 3 | ||||
-rw-r--r-- | test/files/run/t8197b.scala | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 50744f2d72..b42113c84f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1328,7 +1328,8 @@ trait Infer extends Checkable { eligible else eligible filter (alt => - !mexists(alt.info.paramss)(_.hasDefault) && isApplicableBasedOnArity(alt.tpe, argtpes.length, varargsStar, tuplingAllowed = true) + !alt.info.params.exists(_.hasDefault) // run/t8197b first parameter list only! + && isApplicableBasedOnArity(alt.tpe, argtpes.length, varargsStar, tuplingAllowed = true) ) } diff --git a/test/files/run/t8197b.scala b/test/files/run/t8197b.scala new file mode 100644 index 0000000000..8b3e0af0db --- /dev/null +++ b/test/files/run/t8197b.scala @@ -0,0 +1,8 @@ +object O { + def foo[T](t: T) = 0 + def foo(s: String)(implicit i: DummyImplicit = null) = 1 +} + +object Test extends App { + assert(O.foo("") == 1) +} |