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
I can't find a rule to say that this is a compile-time error in the feature specification.
However, I do think it should be an error: The augmenting declaration (presumably) adds an initializing expression to the declaration of x in lib.dart, but at the same time it eliminates the implicitly induced setter (which is needed because we must be able to initialize the variable, but it has a restricted semantics because we are not allowed to mutate the value, that is, it will throw on every non-first invocation).
I think it is a unique property of this kind of augmentation that it eliminates a setter which would otherwise exist (I don't think we have any other augmentations that will eliminate any entity).
(I think we are just about to decide that library augmentations should just be part files, but that shouldn't change anything.)
@dart-lang/language-team, WDYT?
The text was updated successfully, but these errors were encountered:
Interesting - yes it does sound like a unique property of this kind of augmentation, which is not desirable.
I think it would be reasonable to say that an augmentation is not allowed to introduce an initializer for a late final variable.
This can't be expressed through the macro API unfortunately, but we can just rely on the general purpose error (to be specified in the augmentation library spec).
From the general rule of augmentations not changing signatures, an augmentation should not be allowed to add an initializer to a late final variable that has none.
A late final with no initializer has a setter, and a late final with an initializer does not, so adding an initializer should significantly change the signature.
Consider the following program:
I can't find a rule to say that this is a compile-time error in the feature specification.
However, I do think it should be an error: The augmenting declaration (presumably) adds an initializing expression to the declaration of
x
inlib.dart
, but at the same time it eliminates the implicitly induced setter (which is needed because we must be able to initialize the variable, but it has a restricted semantics because we are not allowed to mutate the value, that is, it will throw on every non-first invocation).I think it is a unique property of this kind of augmentation that it eliminates a setter which would otherwise exist (I don't think we have any other augmentations that will eliminate any entity).
(I think we are just about to decide that library augmentations should just be part files, but that shouldn't change anything.)
@dart-lang/language-team, WDYT?
The text was updated successfully, but these errors were encountered: