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 @@ -495,17 +495,16 @@ extension JavaTranslator {
495495 """
496496
497497 let initSyntax : DeclSyntax = """
498- public init? (_ enumValue: \( raw: name) , environment: JNIEnvironment) throws {
499- let classObj = try JavaClass<Self>(in: environment)
498+ public init(_ enumValue: \( raw: name) , environment: JNIEnvironment) {
499+ let classObj = try! JavaClass<Self>(in: environment)
500500 switch enumValue {
501501 \( raw: enumFields. map {
502- let caseName = $0. getName ( )
503502 return """
504- case . \( caseName ) :
505- if let \( caseName ) = classObj. \( caseName ) {
506- self = \( caseName )
503+ case . \( $0 . getName ( ) ) :
504+ if let \( $0 . getName ( ) ) = classObj. \( $0 . getName ( ) ) {
505+ self = \( $0 . getName ( ) )
507506 } else {
508- return nil
507+ fatalError( " Enum value \( $0 . getName ( ) ) was unexpectedly nil, please re-run Java2Swift on the most updated Java class " )
509508 }
510509 """
511510 } . 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