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
The rules for export forwarders are changed as follows.
Previously, all export forwarders were declared `final`. Now, only term members are declared `final`. Type aliases left aside.
This makes it possible to export the same type member into several traits and then mix these traits in the same class. `typeclass-aggregates.scala` shows why this is essential to be able to combine multiple givens with type members.
The change does not lose safety since different type aliases would in any case lead to uninstantiatable classes.
Copy file name to clipboardExpand all lines: docs/_docs/reference/other-new-features/export.md
+13-3
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,12 @@ final def print(bits: BitMap): Unit = printUnit.print(bits)
37
37
finaltypePrinterType= printUnit.PrinterType
38
38
```
39
39
40
-
They can be accessed inside `Copier` as well as from outside:
40
+
With the experimental `modularity` language import, only exported methods and values are final, whereas the generated `PrinterType` would be a simple type alias
41
+
```scala
42
+
typePrinterType= printUnit.PrinterType
43
+
```
44
+
45
+
These aliases can be accessed inside `Copier` as well as from outside:
41
46
42
47
```scala
43
48
valcopier=newCopier
@@ -90,12 +95,17 @@ export O.*
90
95
```
91
96
92
97
Export aliases copy the type and value parameters of the members they refer to.
93
-
Export aliases are always `final`. Aliases of given instances are again defined as givens (and aliases of old-style implicits are `implicit`). Aliases of extensions are again defined as extensions. Aliases of inline methods or values are again defined `inline`. There are no other modifiers that can be given to an alias. This has the following consequences for overriding:
98
+
Export aliases of term members are always `final`. Aliases of given instances are again defined as givens (and aliases of old-style implicits are `implicit`). Aliases of extensions are again defined as extensions. Aliases of inline methods or values are again defined `inline`. There are no other modifiers that can be given to an alias. This has the following consequences for overriding:
94
99
95
-
- Export aliases cannot be overridden, since they are final.
100
+
- Export aliases of methods or fields cannot be overridden, since they are final.
96
101
- Export aliases cannot override concrete members in base classes, since they are
97
102
not marked `override`.
98
103
- However, export aliases can implement deferred members of base classes.
104
+
- Export type aliases are normally also final, except when the experimental
105
+
language import `modularity` is present. The general
106
+
rules for type aliases ensure in any case that if there are several type aliases in a class,
107
+
they must agree on their right hand sides, or the class could not be instantiated.
108
+
So dropping the `final` for export type aliases is safe.
99
109
100
110
Export aliases for public value definitions that are accessed without
0 commit comments