KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference)
KT-335 Type inference fails on Collections.sort
This commit is contained in:
@@ -376,6 +376,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
|||||||
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
|
||||||
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor;
|
TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||||
|
if (!unknownTypes.containsKey(descriptor)) return null;
|
||||||
println(descriptor + " |-> " + getValue(descriptor));
|
println(descriptor + " |-> " + getValue(descriptor));
|
||||||
return new TypeProjection(getValue(descriptor));
|
return new TypeProjection(getValue(descriptor));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference)
|
||||||
|
// KT-335 Type inference fails on Collections.sort
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
import java.lang.Comparable as Comparable
|
||||||
|
|
||||||
|
fun <T : java.lang.Comparable<T>> List<T>.sort() {
|
||||||
|
Collections.sort(this) // Error here
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> List<T>.plus(other : List<T>) : List<T> {
|
||||||
|
val result = ArrayList(this)
|
||||||
|
return result
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user