K2: for Java source override, don't compare return types in override checker

#KT-57044 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-06-15 15:00:17 +02:00
committed by Space Team
parent 7d7256536c
commit 0c61ce61c3
9 changed files with 122 additions and 1 deletions
@@ -250,7 +250,18 @@ class JavaOverrideChecker internal constructor(
return false
}
if (considerReturnTypeKinds && !doesReturnTypesHaveSameKind(overrideCandidate, baseDeclaration)) return false
if (overrideCandidate.origin == FirDeclarationOrigin.Java.Source && baseDeclaration.origin == FirDeclarationOrigin.Source) {
// For override from Java source against the Kotlin base the following check of return type kinds is not important
// From the other side, it can provoke problems in case baseDeclaration is from source and has an implicit return type
// which is not yet resolved (see KT-57044)
return true
}
// See test compiler/testData/compileKotlinAgainstCustomBinaries/incorrectJavaSignature
// and relevant commit message (360d6741)
if (considerReturnTypeKinds && !doesReturnTypesHaveSameKind(overrideCandidate, baseDeclaration)) {
return false
}
return true
}