File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -484,17 +484,16 @@ extension JavaTranslator {
484
484
"""
485
485
486
486
let initSyntax : DeclSyntax = """
487
- public init? (_ enumValue: \( raw: name) , environment: JNIEnvironment) throws {
488
- let classObj = try JavaClass<Self>(in: environment)
487
+ public init(_ enumValue: \( raw: name) , environment: JNIEnvironment) {
488
+ let classObj = try! JavaClass<Self>(in: environment)
489
489
switch enumValue {
490
490
\( raw: enumFields. map {
491
- let caseName = $0. getName ( )
492
491
return """
493
- case . \( caseName ) :
494
- if let \( caseName ) = classObj. \( caseName ) {
495
- self = \( caseName )
492
+ case . \( $0 . getName ( ) ) :
493
+ if let \( $0 . getName ( ) ) = classObj. \( $0 . getName ( ) ) {
494
+ self = \( $0 . getName ( ) )
496
495
} else {
497
- return nil
496
+ fatalError( " Enum value \( $0 . getName ( ) ) was unexpectedly nil, please re-run Java2Swift on the most updated Java class " )
498
497
}
499
498
"""
500
499
} . joined ( separator: " \n " ) )
Original file line number Diff line number Diff line change @@ -66,13 +66,13 @@ class Java2SwiftTests: XCTestCase {
66
66
return MonthCases.APRIL
67
67
}
68
68
""" ,
69
- " public init? (_ enumValue: MonthCases, environment: JNIEnvironment) throws { " ,
69
+ " public init(_ enumValue: MonthCases, environment: JNIEnvironment) { " ,
70
70
"""
71
71
case .APRIL:
72
72
if let APRIL = classObj.APRIL {
73
73
self = APRIL
74
74
} else {
75
- return nil
75
+ fatalError( " Enum value APRIL was unexpectedly nil, please re-run Java2Swift on the most updated Java class " )
76
76
}
77
77
""" ,
78
78
"""
You can’t perform that action at this time.
0 commit comments