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
Don't drop transparent classes. This means that a type such as
```
Any { type T = A } & Object
```
will be kept as is. Previously it was reduced to `Any { type T = A }`
but that feels wrong.
Transparent classes now only enter the picture for typing union types. If the
join of a union types consists only of transparent traits or classes, keep it
instead of widening it.
Copy file name to clipboardExpand all lines: docs/_docs/reference/other-new-features/transparent-traits.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ declared transparent.
85
85
86
86
Transparent traits and classes can be given as explicit types as usual. But they are often elided when types are inferred. Roughly, the rules for type inference imply the following.
87
87
88
-
- Transparent traits and classes are dropped from intersections where possible.
88
+
- Transparent traits are dropped from intersections where possible.
89
89
- Union types are not widened if widening would result in only transparent supertypes.
90
90
91
91
The precise rules are as follows:
@@ -94,8 +94,8 @@ The precise rules are as follows:
94
94
- where that type is not higher-kinded,
95
95
- and where `B` is its known upper bound or `Any` if none exists:
96
96
- If the type inferred so far is of the form `T1 & ... & Tn` where
97
-
`n >= 1`, replace the maximal number of transparent `Ti`s by `Any`, while ensuring that
97
+
`n >= 1`, replace the maximal number of transparent traits `Ti`s by `Any`, while ensuring that
98
98
the resulting type is still a subtype of the bound `B`.
99
-
- However, do not perform this widening if all transparent types `Ti` can get replaced in that way. This clause ensures that a single transparent trait instance such as [`Product`](https://scala-lang.org/api/3.x/scala/Product.html) is not widened to [`Any`](https://scala-lang.org/api/3.x/scala/Any.html). Transparent trait instances are only dropped when they appear in conjunction with some other type.
99
+
- However, do not perform this widening if all types `Ti` can get replaced in that way. This clause ensures that a single transparent trait instance such as [`Product`](https://scala-lang.org/api/3.x/scala/Product.html) is not widened to [`Any`](https://scala-lang.org/api/3.x/scala/Any.html). Transparent trait instances are only dropped when they appear in conjunction with some other type.
100
100
101
-
- If the original type was a is union type that got widened in a previous step to a product consisting only of transparent types, keep the original union type instead of its widened form.
101
+
- If the original type was a is union type that got widened in a previous step to a product consisting only of transparent traits and classes, keep the original union type instead of its widened form.
0 commit comments