@@ -4,7 +4,7 @@ Author: Bob Nystrom
4
4
5
5
Status: Accepted
6
6
7
- Version 1.1
7
+ Version 1.2
8
8
9
9
Experiment flag: class-modifiers
10
10
@@ -599,18 +599,40 @@ non-breaking.
599
599
600
600
Let ` n ` be the language version this proposal ships in. Then:
601
601
602
+ * ` base ` , ` interface ` , ` final ` , and ` mixin ` can only be applied to classes and
603
+ mixins in libraries whose language version is ` >= n ` .
604
+
605
+ * When the ` base ` , ` interface ` , ` final ` , ` mixin ` , or ` sealed ` modifiers are
606
+ placed on a class or mixin, the resulting restrictions apply to all other
607
+ libraries, even libraries whose version is ` < n ` .
608
+
609
+ * In other words, we gate being able to _ author_ the restrictions to
610
+ libraries on version ` n ` . But once a type has those restrictions, they apply
611
+ to all other libraries, regardless of the versions of those libraries.
612
+ "Ignorance of the law is no defense."*
613
+
614
+ ** TODO:** Decide if we want to carve out an exception to this rule for the
615
+ SDK core libraries.
616
+
602
617
* A class declaration in a library whose language version is ` < n ` can be used
603
- as a mixin as long as the class meets the mixin restrictions. * This is is
618
+ as a mixin as long as the class meets the mixin restrictions. This is is
604
619
true even if the library where the class is being used as a mixin is `>=
605
- n`.*
620
+ n`.
621
+
622
+ * For libraries whose version is ` < n ` , we can't tell if the intent of
623
+ ` class ` was "just a class" or "both a class and a mixin". For compatibility,
624
+ we assume the latter, even if the class is being used as a mixin in a
625
+ library whose version is ` >= n ` and where it does happen to be possible to
626
+ distinguish those two intents.*
606
627
607
628
* A class declaration in a library whose version is ` >= n ` must be explicitly
608
- marked ` mixin class ` to allow the class to be used in a ` with ` clause. * This
609
- is true even if the library where the class is being used as a mixin is `<
610
- n`.*
629
+ marked ` mixin class ` to allow the class to be used as a mixin. This is true
630
+ even if the library where the class is being used as a mixin is ` < n ` .
611
631
612
- * The ` base ` , ` interface ` , and ` final ` modifiers on classes and mixins can
613
- only be used in libraries whose language version is ` >= n ` .
632
+ * When a class is in a library where it possible to distinguish between
633
+ whether the class is intended to use it as a mixin or not, the author is
634
+ obliged to, and that intent applies to all other libraries regardless of
635
+ their version.*
614
636
615
637
### Compatibility
616
638
@@ -622,6 +644,10 @@ needed.
622
644
623
645
## Changelog
624
646
647
+ 1.2
648
+
649
+ - Specify how all modifiers interact with language versioning (#2725 ).
650
+
625
651
1.1
626
652
627
653
- Clarify that all modifiers are gated behind a language version.
0 commit comments