File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -127,9 +127,29 @@ extension Swift2JavaTranslator {
127
127
parameterName: String
128
128
) throws -> LoweredParameters {
129
129
switch type {
130
- case . function, . metatype , . optional:
130
+ case . function, . optional:
131
131
throw LoweringError . unhandledType ( type)
132
132
133
+ case . metatype( let instanceType) :
134
+ return LoweredParameters (
135
+ cdeclToOriginal: . unsafeCastPointer(
136
+ . passDirectly( parameterName) ,
137
+ swiftType: instanceType
138
+ ) ,
139
+ cdeclParameters: [
140
+ SwiftParameter (
141
+ convention: . byValue,
142
+ parameterName: parameterName,
143
+ type: . nominal(
144
+ SwiftNominalType (
145
+ nominalTypeDecl: swiftStdlibTypes. unsafeRawPointerDecl
146
+ )
147
+ )
148
+ )
149
+ ] ,
150
+ javaFFMParameters: [ . SwiftPointer]
151
+ )
152
+
133
153
case . nominal( let nominal) :
134
154
// Types from the Swift standard library that we know about.
135
155
if nominal. nominalTypeDecl. moduleName == " Swift " ,
Original file line number Diff line number Diff line change @@ -117,14 +117,15 @@ final class FunctionLoweringTests {
117
117
)
118
118
}
119
119
120
- @Test ( " Lowering metatypes " , . disabled ( " Metatypes are not yet lowered " ) )
120
+ @Test ( " Lowering metatypes " )
121
121
func lowerMetatype( ) throws {
122
122
try assertLoweredFunction ( """
123
123
func f(t: Int.Type) { }
124
124
""" ,
125
125
expectedCDecl: """
126
- func f(t: UnsafeRawPointer) -> () {
127
- // implementation
126
+ @_cdecl( " c_f " )
127
+ func c_f(_ t: UnsafeRawPointer) {
128
+ f(t: unsafeBitCast(t, to: Int.self))
128
129
}
129
130
"""
130
131
)
You can’t perform that action at this time.
0 commit comments