You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If type parameters cannot be inferred from the context, an error is shown. This includes optional type parameters. For classes, this behavior prevents initializing the type parameters to some initial state:
enum TrainingState {
Untrained
Trained
}
class Regressor1<State sub TrainingState = TrainingState.Untrained>() {
@Pure fun fit() -> regressor: Regressor1<TrainingState.Trained>
}
Desired solution
For classes, don't show this error for optional type parameters.
Keep the check for functions.
Possible alternatives (optional)
No response
Screenshots (optional)
No response
Additional Context (optional)
No response
The text was updated successfully, but these errors were encountered:
… inferred (#1090)
Closes#1084
### Summary of Changes
Optional type parameters of classes are now always allowed, even if they
can never be inferred from their usage in the constructor.
This is useful to initialize them to some default value upon
instantiation and override this value later, e.g. in return types of
functions. See #1084 for an example.
Is your feature request related to a problem?
If type parameters cannot be inferred from the context, an error is shown. This includes optional type parameters. For classes, this behavior prevents initializing the type parameters to some initial state:
Desired solution
Possible alternatives (optional)
No response
Screenshots (optional)
No response
Additional Context (optional)
No response
The text was updated successfully, but these errors were encountered: