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 {
127127 parameterName: String
128128 ) throws -> LoweredParameters {
129129 switch type {
130- case . function, . metatype , . optional:
130+ case . function, . optional:
131131 throw LoweringError . unhandledType ( type)
132132
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+
133153 case . nominal( let nominal) :
134154 // Types from the Swift standard library that we know about.
135155 if nominal. nominalTypeDecl. moduleName == " Swift " ,
Original file line number Diff line number Diff line change @@ -117,14 +117,15 @@ final class FunctionLoweringTests {
117117 )
118118 }
119119
120- @Test ( " Lowering metatypes " , . disabled ( " Metatypes are not yet lowered " ) )
120+ @Test ( " Lowering metatypes " )
121121 func lowerMetatype( ) throws {
122122 try assertLoweredFunction ( """
123123 func f(t: Int.Type) { }
124124 """ ,
125125 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))
128129 }
129130 """
130131 )
You can’t perform that action at this time.
0 commit comments