K2: Fix false-positive RETURN_TYPE_MISMATCH_ON_OVERRIDE
The reason was that `substitutorByMap` ignored the difference between `T` and `T?` ^KT-57001 Fixed
This commit is contained in:
committed by
Space Team
parent
ac8cbcafb4
commit
d9ca77f716
+6
@@ -12564,6 +12564,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nullableTypeParameterScope.kt")
|
||||||
|
public void testNullableTypeParameterScope() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/generics/nullableTypeParameterScope.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
||||||
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -12564,6 +12564,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nullableTypeParameterScope.kt")
|
||||||
|
public void testNullableTypeParameterScope() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/generics/nullableTypeParameterScope.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
||||||
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -12564,6 +12564,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nullableTypeParameterScope.kt")
|
||||||
|
public void testNullableTypeParameterScope() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/generics/nullableTypeParameterScope.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
||||||
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -12570,6 +12570,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nullableTypeParameterScope.kt")
|
||||||
|
public void testNullableTypeParameterScope() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/generics/nullableTypeParameterScope.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
||||||
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -173,7 +173,7 @@ abstract class AbstractConeSubstitutor(protected val typeContext: ConeTypeContex
|
|||||||
fun substitutorByMap(substitution: Map<FirTypeParameterSymbol, ConeKotlinType>, useSiteSession: FirSession): ConeSubstitutor {
|
fun substitutorByMap(substitution: Map<FirTypeParameterSymbol, ConeKotlinType>, useSiteSession: FirSession): ConeSubstitutor {
|
||||||
// If all arguments match parameters, then substitutor isn't needed
|
// If all arguments match parameters, then substitutor isn't needed
|
||||||
if (substitution.all { (parameterSymbol, argumentType) ->
|
if (substitution.all { (parameterSymbol, argumentType) ->
|
||||||
(argumentType as? ConeTypeParameterType)?.lookupTag?.typeParameterSymbol == parameterSymbol
|
(argumentType as? ConeTypeParameterType)?.lookupTag?.typeParameterSymbol == parameterSymbol && !argumentType.isMarkedNullable
|
||||||
}
|
}
|
||||||
) return ConeSubstitutor.Empty
|
) return ConeSubstitutor.Empty
|
||||||
return ConeSubstitutorByMap(substitution, useSiteSession)
|
return ConeSubstitutorByMap(substitution, useSiteSession)
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// ISSUE: KT-57001
|
||||||
|
|
||||||
|
interface ConverterFromString<T> {
|
||||||
|
|
||||||
|
fun ofS(s: String): T
|
||||||
|
|
||||||
|
fun nullable(nullText: String): ConverterFromString<T?> = object: ConverterFromString<T?> {
|
||||||
|
override fun ofS(s: String): T? = if (s == nullText) null else this@ConverterFromString.ofS(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -12570,6 +12570,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/localClassTypeRefWithTypeParameterFromFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nullableTypeParameterScope.kt")
|
||||||
|
public void testNullableTypeParameterScope() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/generics/nullableTypeParameterScope.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
@TestMetadata("outerTypeParametersInNestedClasses.kt")
|
||||||
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
public void testOuterTypeParametersInNestedClasses() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user