New J2K: Add checking for receiver type in for conversion's indicesByCollectionSize
This commit is contained in:
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
|
||||||
|
|||||||
Reference in New Issue
Block a user