A non-generic function is always more speciic than a generic function

Example:
fun <T> array(vararg array : T) = array
fun array(vararg array : Char) = array

fun test() {
    array('1', '2') // ambiguity
}
This commit is contained in:
Andrey Breslav
2011-11-12 18:20:16 +04:00
parent 5bb226627f
commit bf4fef9a03
2 changed files with 9 additions and 0 deletions
@@ -70,6 +70,7 @@ public class OverloadingConflictResolver {
* Int < Short < Byte
*/
private <Descriptor extends CallableDescriptor> boolean moreSpecific(Descriptor f, Descriptor g, boolean discriminateGenericDescriptors) {
if (discriminateGenericDescriptors && !isGeneric(f) && isGeneric(g)) return true;
if (OverridingUtil.overrides(f, g)) return true;
if (OverridingUtil.overrides(g, f)) return false;
@@ -0,0 +1,8 @@
// A generic funciton is always less specific than a non-generic one
fun foo<T>(t : T) : Unit {}
fun foo(i : Int) : Int = 1
fun test() {
foo(1) : Int
foo("s") : Unit
}