Fix type mapping for parameter of Collection<Int>::remove override

In the case the single parameter of override has `Integer` type instead
of `int` type (while in common case it would be just `int`)

See the comment inside forceSingleValueParameterBoxing for clarification

 #KT-19892 Fixed
This commit is contained in:
Denis Zharkov
2017-08-31 12:38:08 +03:00
parent 73c139d250
commit ed79891ee6
7 changed files with 59 additions and 3 deletions
@@ -52,7 +52,9 @@ fun FunctionDescriptor.computeJvmDescriptor(withReturnType: Boolean = true)
// Boxing is only necessary for 'remove(E): Boolean' of a MutableCollection<Int> implementation
// Otherwise this method might clash with 'remove(I): E' defined in the java.util.List JDK interface (mapped to kotlin 'removeAt')
fun forceSingleValueParameterBoxing(f: FunctionDescriptor): Boolean {
fun forceSingleValueParameterBoxing(f: CallableDescriptor): Boolean {
if (f !is FunctionDescriptor) return false
if (f.valueParameters.size != 1 || f.isFromJavaOrBuiltins() || f.name.asString() != "remove") return false
if ((f.original.valueParameters.single().type.mapToJvmType() as? JvmType.Primitive)?.jvmPrimitiveType != JvmPrimitiveType.INT) return false