K2: for Java source override, don't compare return types in override checker
#KT-57044 Fixed
This commit is contained in:
committed by
Space Team
parent
7d7256536c
commit
0c61ce61c3
+12
@@ -6969,6 +6969,18 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/NamedParameterInConcurrentMap.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit.kt")
|
||||
public void testOverriddenFunctionReturningUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit2.kt")
|
||||
public void testOverriddenFunctionReturningUnit2() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierPriority.kt")
|
||||
public void testQualifierPriority() throws Exception {
|
||||
|
||||
+12
@@ -6969,6 +6969,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/NamedParameterInConcurrentMap.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit.kt")
|
||||
public void testOverriddenFunctionReturningUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit2.kt")
|
||||
public void testOverriddenFunctionReturningUnit2() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierPriority.kt")
|
||||
public void testQualifierPriority() throws Exception {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FILE: K.kt
|
||||
public open class K : R|kotlin/Any| {
|
||||
public constructor(): R|K| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun test(): R|kotlin/Unit| {
|
||||
^test Q|kotlin/Unit|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun jk(): R|kotlin/Unit| {
|
||||
R|/JK.JK|().R|/JK.test|()
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// FILE: JK.java
|
||||
|
||||
public class JK extends K {
|
||||
@Override
|
||||
public void test() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
open class K {
|
||||
open fun test() = Unit
|
||||
}
|
||||
|
||||
fun jk() {
|
||||
JK().test()
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FILE: K.kt
|
||||
public final fun jk(): R|kotlin/Unit| {
|
||||
^jk R|/JK.JK|().R|/JK.test|()
|
||||
}
|
||||
public open class K : R|kotlin/Any| {
|
||||
public constructor(): R|K| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun test(): R|kotlin/Unit| {
|
||||
^test Q|kotlin/Unit|
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// FILE: JK.java
|
||||
|
||||
public class JK extends K {
|
||||
@Override
|
||||
public void test() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
fun jk() = JK().test()
|
||||
|
||||
open class K {
|
||||
open fun test() = Unit
|
||||
}
|
||||
+12
@@ -6969,6 +6969,18 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/NamedParameterInConcurrentMap.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit.kt")
|
||||
public void testOverriddenFunctionReturningUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit2.kt")
|
||||
public void testOverriddenFunctionReturningUnit2() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierPriority.kt")
|
||||
public void testQualifierPriority() throws Exception {
|
||||
|
||||
+12
@@ -6969,6 +6969,18 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/NamedParameterInConcurrentMap.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit.kt")
|
||||
public void testOverriddenFunctionReturningUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overriddenFunctionReturningUnit2.kt")
|
||||
public void testOverriddenFunctionReturningUnit2() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/overriddenFunctionReturningUnit2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierPriority.kt")
|
||||
public void testQualifierPriority() throws Exception {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user