Skip to content

Commit a851541

Browse files
committed
Improve type name collision detection to rename only necessary types.
1 parent 5ed5d7b commit a851541

File tree

5 files changed

+23
-59
lines changed

5 files changed

+23
-59
lines changed

SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/SkiePhaseScheduler.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ import co.touchlab.skie.phases.swift.CompileSwiftPhase
6262
import co.touchlab.skie.phases.swift.GenerateSirFileCodePhase
6363
import co.touchlab.skie.phases.swift.SwiftCacheSetupPhase
6464
import co.touchlab.skie.phases.swift.WriteSirFileContentToDiskPhase
65-
import co.touchlab.skie.phases.typeconflicts.RenameNestedKotlinTypesConflictingWithKeywordsPhase
66-
import co.touchlab.skie.phases.typeconflicts.RenameNestedTypesConflictingWithExternalTypesPhase
67-
import co.touchlab.skie.phases.typeconflicts.RenameSkieNamespacesConflictingWithKeywordsPhase
65+
import co.touchlab.skie.phases.typeconflicts.RenameTypesConflictingWithKeywordsPhase
6866
import co.touchlab.skie.phases.typeconflicts.RenameTypesConflictingWithKotlinModulePhase
6967
import co.touchlab.skie.phases.typeconflicts.RenameTypesConflictsWithOtherTypesPhase
7068
import co.touchlab.skie.phases.typeconflicts.TemporarilyRenameTypesConflictingWithExternalModulesPhase
@@ -137,10 +135,8 @@ class SkiePhaseScheduler {
137135
StripKonanCallableDeclarationManglingPhase,
138136

139137
FixNamesOfInaccessibleNestedClassesPhase,
140-
RenameSkieNamespacesConflictingWithKeywordsPhase,
141138

142-
RenameNestedTypesConflictingWithExternalTypesPhase,
143-
RenameNestedKotlinTypesConflictingWithKeywordsPhase,
139+
RenameTypesConflictingWithKeywordsPhase,
144140
RenameTypesConflictingWithKotlinModulePhase,
145141

146142
KotlinRuntimeHidingPhase,

SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/typeconflicts/RenameNestedKotlinTypesConflictingWithKeywordsPhase.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/typeconflicts/RenameNestedTypesConflictingWithExternalTypesPhase.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/typeconflicts/RenameSkieNamespacesConflictingWithKeywordsPhase.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package co.touchlab.skie.phases.typeconflicts
2+
3+
import co.touchlab.skie.phases.SirPhase
4+
5+
object RenameTypesConflictingWithKeywordsPhase : SirPhase {
6+
7+
private val problematicKeywords = listOf(
8+
"Protocol",
9+
"Self",
10+
"Type",
11+
)
12+
13+
context(SirPhase.Context)
14+
override fun execute() {
15+
sirProvider.allLocalTypeDeclarations
16+
.filter { it.simpleName in problematicKeywords }
17+
.forEach {
18+
it.baseName += "_"
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)