@@ -7,6 +7,7 @@ import co.touchlab.skie.phases.apinotes.builder.ApiNotes
7
7
import co.touchlab.skie.phases.apinotes.parser.ExternalApiNotesParser
8
8
import co.touchlab.skie.sir.SirFqName
9
9
import co.touchlab.skie.sir.element.SirClass
10
+ import co.touchlab.skie.sir.element.SirTypeParameterParent
10
11
import co.touchlab.skie.util.Command
11
12
import java.io.File
12
13
@@ -56,6 +57,7 @@ class ConfigureExternalOirTypesBridgingPhase(
56
57
objCName = it.objCFqName,
57
58
swiftName = it.swiftFqName,
58
59
bridgeSwiftName = it.bridgeFqName,
60
+ importAsNonGeneric = it.importAsNonGeneric,
59
61
)
60
62
}
61
63
.filter { it.swiftName != null || it.bridgeSwiftName != null }
@@ -75,15 +77,15 @@ class ConfigureExternalOirTypesBridgingPhase(
75
77
private fun configureBridging (apiNotesEntry : ApiNotesEntry ) {
76
78
val oirClass = oirProvider.findExistingExternalOirClass(apiNotesEntry.moduleName, apiNotesEntry.objCName) ? : return
77
79
78
- val module = sirProvider.getExternalModule(apiNotesEntry.moduleName)
79
-
80
80
if (oirClass.bridgedSirClass == null && apiNotesEntry.bridgeSwiftName != null ) {
81
- val bridgeFqName = SirFqName (module, apiNotesEntry.bridgeSwiftName)
81
+ val bridgeFqName = apiNotesEntry.bridgeSwiftName.asApiNotesSirFqName( )
82
82
83
83
oirClass.bridgedSirClass = getOrCreateSirClass(bridgeFqName)
84
84
}
85
85
86
86
if (apiNotesEntry.swiftName != null ) {
87
+ val module = sirProvider.getExternalModule(apiNotesEntry.moduleName)
88
+
87
89
val fqName = SirFqName (module, apiNotesEntry.swiftName)
88
90
89
91
if (fqName.parent != null ) {
@@ -93,7 +95,22 @@ class ConfigureExternalOirTypesBridgingPhase(
93
95
oirClass.originalSirClass.baseName = fqName.simpleName
94
96
}
95
97
96
- // WIP importAsNonGeneric
98
+ if (apiNotesEntry.importAsNonGeneric) {
99
+ oirClass.originalSirClass.typeParameters.toList().forEach {
100
+ it.parent = SirTypeParameterParent .None
101
+ }
102
+ }
103
+ }
104
+
105
+ private fun String.asApiNotesSirFqName (): SirFqName {
106
+ val parts = split(' .' )
107
+
108
+ check(parts.size == 2 ) { " Invalid ApiNotes fq name: $this . Expected format is \$ moduleName.\$ className" }
109
+
110
+ val module = sirProvider.getExternalModule(parts[0 ])
111
+ val className = parts[1 ]
112
+
113
+ return SirFqName (module, className)
97
114
}
98
115
99
116
private fun getOrCreateSirClass (fqName : SirFqName ): SirClass {
@@ -120,5 +137,11 @@ class ConfigureExternalOirTypesBridgingPhase(
120
137
}
121
138
}
122
139
123
- private data class ApiNotesEntry (val moduleName : String , val objCName : String , val swiftName : String? , val bridgeSwiftName : String? )
140
+ private data class ApiNotesEntry (
141
+ val moduleName : String ,
142
+ val objCName : String ,
143
+ val swiftName : String? ,
144
+ val bridgeSwiftName : String? ,
145
+ val importAsNonGeneric : Boolean ,
146
+ )
124
147
}
0 commit comments