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:
+1
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user