Hi! I moved my domain logic classes to a new modul...
# announcements
i
Hi! I moved my domain logic classes to a new module, and getting this error:
Smart cast to 'UserInput.Some' is impossible, because 'alert.earliestSymptomTime' is a public API property declared in different module 
code:
Copy code
when (alert.earliestSymptomTime) {
    is UserInput.Some -> alert.earliestSymptomTime.value.value
    is UserInput.None -> null
}
Why does it happen? Seems weird. And is there a way to fix it without having to cast? I didn't expect that modularizing my app would lead to a decline in code quality 😕
j
Copy code
when (val earliestSymptomTime = alert.earliestSymptomTime) {
    is UserInput.Some -> earliestSymptomTime.value.value
    is UserInput.None -> null
}
So you can solve the problem
i
ah my bad, I knew this construct but was confused by the migration, thanks
k
I would go with a shorter name
r
To answer why it happens, modules can be compiled independently, so you could theoretically compile this module, then add a new
UserInput
type and compile the domain logic module. Now if you run, you're already compiled
when
is no longer exhausted.
j
@Ruckus how?
k
No the issue is that
earliestSymptomTime
could return different values in the when argument and in the when case
r
Sorry, you're correct. I guess I didn't read carefully enough.