[K2] Report CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR for class hierarchies

Previously it wasn't reported in FIR for ConcurrentHashMap inheritors
because the receiver id hasn't matched CHM.contains id
Fixed by unwrapping origin of the call in case of fake overrides

^KT-55606 fixed
This commit is contained in:
Vsevolod Tolstopyatov
2023-01-17 09:46:25 +00:00
committed by Space Team
parent b09561c3c3
commit 21fe0e80ff
4 changed files with 291 additions and 56 deletions
@@ -20,9 +20,10 @@ import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
import org.jetbrains.kotlin.util.OperatorNameConventions
/**
* This checker detects if call by operator convention to a Java method violates some expected contract:
* - "key in map" commonly resolves to an stdlib extension that calls Map.containsKey(),
* but there's a member in ConcurrentHashMap with acceptable signature that delegates to `containsValue` instead
* This checker detects if a call by operator 'contains' convention to a Java method violates the expected contract:
* * "key in map" commonly resolves to stdlib extension that calls Map.containsKey(),
* but there's a member in ConcurrentHashMap with acceptable signature that delegates to `containsValue` instead,
* leading to an unexpected result. See KT-18053
*/
object InconsistentOperatorFromJavaCallChecker : CallChecker {
private val CONCURRENT_HASH_MAP_FQ_NAME = FqName("java.util.concurrent.ConcurrentHashMap")