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 {
484484 """
485485
486486 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)
489489 switch enumValue {
490490 \( raw: enumFields. map {
491- let caseName = $0. getName ( )
492491 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 ( ) )
496495 } else {
497- return nil
496+ fatalError( " Enum value \( $0 . getName ( ) ) was unexpectedly nil, please re-run Java2Swift on the most updated Java class " )
498497 }
499498 """
500499 } . joined ( separator: " \n " ) )
Original file line number Diff line number Diff line change @@ -66,13 +66,13 @@ class Java2SwiftTests: XCTestCase {
6666 return MonthCases.APRIL
6767 }
6868 """ ,
69- " public init? (_ enumValue: MonthCases, environment: JNIEnvironment) throws { " ,
69+ " public init(_ enumValue: MonthCases, environment: JNIEnvironment) { " ,
7070 """
7171 case .APRIL:
7272 if let APRIL = classObj.APRIL {
7373 self = APRIL
7474 } else {
75- return nil
75+ fatalError( " Enum value APRIL was unexpectedly nil, please re-run Java2Swift on the most updated Java class " )
7676 }
7777 """ ,
7878 """
You can’t perform that action at this time.
0 commit comments