KT-1835 cannot call a Java API which has a method from(String) and from(String...)

The problem was in the "more specific" relation, that didn't pay enough attention to varargs.
The correct behavior is in the spirit of JLS 15.12.2 (as of Java 5):
 * a fixed-arity function always wins over a variable-arity functions
 * if two vararg functions are compared, their parameters are checked for subtyping.
  In the latter case, the candidates may have different number of formal parameters, so we
  compare the matching parts and then check the rest against the vararg parameter.

 #KT-1835 Fixed
This commit is contained in:
Andrey Breslav
2012-04-20 19:08:29 +04:00
parent da474b961f
commit 45a0873afa
5 changed files with 119 additions and 21 deletions
@@ -0,0 +1,9 @@
fun main(d : D) {
d.`str`from("")
d.`any`from(1)
}
class D {
~any~fun from(vararg a : Any){}
~str~fun from(vararg a : String){}
}