[K/N][K2] K2 behavioral difference with inconsistent inheritance of ObjCName
Support for complex cases with multiple substitution overrides. #KT-64276 Fixed
This commit is contained in:
committed by
Space Team
parent
d69240a2d5
commit
fd4f6c90c7
+3
-2
@@ -75,7 +75,8 @@ object FirNativeObjCNameUtilities {
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter
|
||||
) {
|
||||
val overriddenSymbols = firTypeScope.retrieveDirectOverriddenOf(memberSymbol).map { it.originalForSubstitutionOverride ?: it }
|
||||
val overriddenSymbols =
|
||||
firTypeScope.retrieveDirectOverriddenOf(memberSymbol).map { it.unwrapSubstitutionOverrides() }
|
||||
if (overriddenSymbols.isEmpty()) return
|
||||
val objCNames = overriddenSymbols.map { it.getFirstBaseSymbol(context).getObjCNames(context.session) }
|
||||
if (!objCNames.allNamesEquals()) {
|
||||
@@ -96,7 +97,7 @@ object FirNativeObjCNameUtilities {
|
||||
val session = context.session
|
||||
val ownScope = containingClassLookupTag()?.toSymbol(session)?.fullyExpandedClass(session)?.unsubstitutedScope(context)
|
||||
?: return this
|
||||
val overriddenMemberSymbols = ownScope.retrieveDirectOverriddenOf(this).map { it.originalForSubstitutionOverride ?: it }
|
||||
val overriddenMemberSymbols = ownScope.retrieveDirectOverriddenOf(this).map { it.unwrapSubstitutionOverrides() }
|
||||
return if (overriddenMemberSymbols.isEmpty()) this else overriddenMemberSymbols.first().getFirstBaseSymbol(context)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: kotlin.kt
|
||||
@file:OptIn(kotlin.experimental.ExperimentalObjCName::class)
|
||||
|
||||
fun interface AutoCloseable {
|
||||
@ObjCName("close") fun close()
|
||||
}
|
||||
|
||||
interface BaseStream<T, S : BaseStream<T, S>> : AutoCloseable {
|
||||
override fun close()
|
||||
}
|
||||
|
||||
interface Stream<T> : BaseStream<T, Stream<T>> {}
|
||||
|
||||
open class TerminatableStream<T : TerminatableStream<T>> {
|
||||
@ObjCName("close") open fun close() {}
|
||||
}
|
||||
|
||||
class StreamImpl<T> : TerminatableStream<StreamImpl<T>>, Stream<T> {
|
||||
constructor() : super() {}
|
||||
}
|
||||
+6
@@ -108,6 +108,12 @@ public class DiagnosticsNativeTestGenerated extends AbstractDiagnosticsNativeTes
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCName6.kt")
|
||||
public void testObjCName6() {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName6.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCNameWIthDifferentSwiftName.kt")
|
||||
public void testObjCNameWIthDifferentSwiftName() {
|
||||
|
||||
+6
@@ -112,6 +112,12 @@ public class FirLightTreeOldFrontendNativeDiagnosticsTestGenerated extends Abstr
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCName6.kt")
|
||||
public void testObjCName6() {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName6.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCNameWIthDifferentSwiftName.kt")
|
||||
public void testObjCNameWIthDifferentSwiftName() {
|
||||
|
||||
+6
@@ -112,6 +112,12 @@ public class FirPsiOldFrontendNativeDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCName6.kt")
|
||||
public void testObjCName6() {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName6.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCNameWIthDifferentSwiftName.kt")
|
||||
public void testObjCNameWIthDifferentSwiftName() {
|
||||
|
||||
Reference in New Issue
Block a user