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 {
495
495
"""
496
496
497
497
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)
500
500
switch enumValue {
501
501
\( raw: enumFields. map {
502
- let caseName = $0. getName ( )
503
502
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 ( ) )
507
506
} else {
508
- return nil
507
+ fatalError( " Enum value \( $0 . getName ( ) ) was unexpectedly nil, please re-run Java2Swift on the most updated Java class " )
509
508
}
510
509
"""
511
510
} . 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