Hello, Before kotlin 1.6.0 I was able to map my sealed classes to swift enums:
Copy code
enum ResponseStateEnum<T: AnyObject> {
case loading
case success(T)
case error(RestClientException)
init(_ state: ResponseState<T>?) {
if state is ResponseStateLoading {
self = .loading
} else if let state = state as? ResponseStateSuccess<T>, let content = state.content {
self = .success(content)
} else if let state = state as? ResponseStateError {
self = .error(state.exception)
} else {
fatalError("ResponseStateEnum not syncronized with ResponseState class")
}
}
}
now I get this log
Copy code
(lldb) po type(of: state!)
PKMMResponseStateLoading
(lldb) po state is PKMMResponseStateLoading
false
Did anything change about sealed classes?
Osman Saral
12/07/2021, 2:56 PM
I was having this issue on non-debug builds. I've investigated and it looks like it was about xcode's optimization level build settings. I wonder why this happens