New J2K: Add checking for receiver type in for conversion's indicesByCollectionSize

This commit is contained in:
Ilya Kirillov
2018-12-03 23:25:43 +03:00
committed by Ilya Kirillov
parent ffbdafbe69
commit 2c7e44f41e
@@ -237,10 +237,11 @@ class ForConversion(private val context: ConversionContext) : RecursiveApplicabl
private fun indicesByCollectionSize(javaSizeCall: JKQualifiedExpression): JKQualifiedExpression? { private fun indicesByCollectionSize(javaSizeCall: JKQualifiedExpression): JKQualifiedExpression? {
val methodCall = javaSizeCall.selector as? JKMethodCallExpression ?: return null val methodCall = javaSizeCall.selector as? JKMethodCallExpression ?: return null
val receiverType = javaSizeCall.receiver.type(context) as? JKClassType ?: return null val receiverType = javaSizeCall.receiver.type(context) ?: return null
if (methodCall.identifier.name == "size"
//TODO check if receiver type is Collection && methodCall.arguments.expressions.isEmpty()
if (methodCall.identifier.name == "size" && methodCall.arguments.expressions.isEmpty()) { && receiverType.isCollectionType(context.symbolProvider)
) {
return toIndicesCall(javaSizeCall) return toIndicesCall(javaSizeCall)
} }
return null return null