Fix ObjCExport mangling top-levels in different files in two-stage mode
This commit is contained in:
committed by
SvyatoslavScherbina
parent
6c1a482539
commit
4c04702636
+3
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.findSourceFile
|
||||
import org.jetbrains.kotlin.backend.konan.cKeywords
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isArray
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
||||
@@ -22,6 +23,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isSubclassOf
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.propertyIfAccessor
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceFile
|
||||
|
||||
internal interface ObjCExportNameTranslator {
|
||||
@@ -791,7 +793,7 @@ private fun ObjCExportMapper.canBeInheritedBySameClass(
|
||||
): Boolean {
|
||||
if (this.isTopLevel(first) || this.isTopLevel(second)) {
|
||||
return this.isTopLevel(first) && this.isTopLevel(second) &&
|
||||
first.source.containingFile == second.source.containingFile
|
||||
first.propertyIfAccessor.findSourceFile() == second.propertyIfAccessor.findSourceFile()
|
||||
}
|
||||
|
||||
val firstClass = this.getClassIfCategory(first) ?: first.containingDeclaration as ClassDescriptor
|
||||
|
||||
@@ -607,6 +607,20 @@ __attribute__((swift_name("ThrowsEmptyKt")))
|
||||
+ (BOOL)throwsEmptyAndReturnError:(NSError * _Nullable * _Nullable)error __attribute__((swift_name("throwsEmpty()")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("TopLevelManglingAKt")))
|
||||
@interface KtTopLevelManglingAKt : KtBase
|
||||
+ (NSString *)foo __attribute__((swift_name("foo()")));
|
||||
@property (class, readonly) NSString *bar __attribute__((swift_name("bar")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("TopLevelManglingBKt")))
|
||||
@interface KtTopLevelManglingBKt : KtBase
|
||||
+ (NSString *)foo __attribute__((swift_name("foo()")));
|
||||
@property (class, readonly) NSString *bar __attribute__((swift_name("bar")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("DelegateClass")))
|
||||
@interface KtDelegateClass : KtBase <KtKotlinReadWriteProperty>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import Kt
|
||||
|
||||
private func testFunctionsInDifferentFilesAreNotMangled() throws {
|
||||
try assertEquals(actual: TopLevelManglingAKt.foo(), expected: "a1")
|
||||
try assertEquals(actual: TopLevelManglingBKt.foo(), expected: "b1")
|
||||
}
|
||||
|
||||
private func testPropertiesInDifferentFilesAreNotMangled() throws {
|
||||
try assertEquals(actual: TopLevelManglingAKt.bar, expected: "a2")
|
||||
try assertEquals(actual: TopLevelManglingBKt.bar, expected: "b2")
|
||||
}
|
||||
|
||||
class TopLevelManglingTests : SimpleTestProvider {
|
||||
override init() {
|
||||
super.init()
|
||||
|
||||
test("TestFunctionsInDifferentFilesAreNotMangled", testFunctionsInDifferentFilesAreNotMangled)
|
||||
test("TestPropertiesInDifferentFilesAreNotMangled", testPropertiesInDifferentFilesAreNotMangled)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package topLevelManglingA
|
||||
|
||||
fun foo() = "a1"
|
||||
val bar = "a2"
|
||||
@@ -0,0 +1,4 @@
|
||||
package topLevelManglingB
|
||||
|
||||
fun foo() = "b1"
|
||||
val bar = "b2"
|
||||
Reference in New Issue
Block a user