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
Fix calculation to drop transparent classes (#16344)
Two fixes:
1. Don't forget about refinements
2. Don't dealias
Fixes#16342Fixes#16338
The first fix is essential for #16342. The second fix is just to keep
types tidy and not open aliases needlessly.
It probably fixes issues #16337 and #16336 as well, but the test cases
were not self-contained, so I could not try them out. It might fix other
recent regressions as well.
The previous incorrect version hid errors in previous regressions #15365
and #16311 which will need to be re-opened now.
Copy file name to clipboardExpand all lines: docs/_docs/reference/other-new-features/transparent-traits.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
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