[FIR] Consider extension receiver type in conflicting members checker

This commit is contained in:
Dmitriy Novozhilov
2021-08-05 14:24:08 +03:00
committed by TeamCityServer
parent cd09c8ba51
commit a9882a86c0
7 changed files with 61 additions and 1 deletions
@@ -2701,6 +2701,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/protobufExt.kt");
}
@TestMetadata("sameValueParametersDifferentReceiver.kt")
public void testSameValueParametersDifferentReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/sameValueParametersDifferentReceiver.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/simple.kt");
@@ -0,0 +1,21 @@
FILE: sameValueParametersDifferentReceiver.kt
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun R|kotlin/String|.foo(from: R|kotlin/String|, to: R|kotlin/String|): R|kotlin/Int| {
^foo Int(1)
}
public final fun <T> R|T|.foo(from: R|kotlin/String|, to: R|kotlin/String|): R|kotlin/Int| {
^foo Int(1)
}
}
public final class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
}
@@ -0,0 +1,11 @@
open class A {
fun String.foo(from: String, to: String): Int {
return 1
}
fun <T> T.foo(from: String, to: String): Int {
return 1
}
}
class B : A()
@@ -3059,6 +3059,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/protobufExt.kt");
}
@Test
@TestMetadata("sameValueParametersDifferentReceiver.kt")
public void testSameValueParametersDifferentReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/sameValueParametersDifferentReceiver.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -3059,6 +3059,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/protobufExt.kt");
}
@Test
@TestMetadata("sameValueParametersDifferentReceiver.kt")
public void testSameValueParametersDifferentReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/sameValueParametersDifferentReceiver.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.utils.addIfNotNull
object FirImplementationMismatchChecker : FirClassChecker() {
@@ -182,6 +183,7 @@ object FirImplementationMismatchChecker : FirClassChecker() {
reporter.reportOn(containingClass.source, FirErrors.VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, symbol, overriddenVar, context)
}
@OptIn(ExperimentalStdlibApi::class)
private fun checkConflictingMembers(
containingClass: FirClass,
context: CheckerContext,
@@ -200,7 +202,10 @@ object FirImplementationMismatchChecker : FirClassChecker() {
}
val sameArgumentGroups = allFunctions.groupBy { function ->
function.valueParameterSymbols.map { it.resolvedReturnTypeRef.coneType }
buildList<ConeKotlinType> {
addIfNotNull(function.resolvedReceiverTypeRef?.type)
function.valueParameterSymbols.mapTo(this) { it.resolvedReturnTypeRef.coneType }
}
}.values
val clashes = sameArgumentGroups.mapNotNull { fs ->
@@ -3059,6 +3059,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/protobufExt.kt");
}
@Test
@TestMetadata("sameValueParametersDifferentReceiver.kt")
public void testSameValueParametersDifferentReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/overrides/sameValueParametersDifferentReceiver.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {