Commit 065f774
Use wildcard type instead of whitebox cast in IsoFields (#1574)
* Use wildcard type instead of whitebox cast in IsoFields
Replace the `whitebox` cast (`asInstanceOf[Expr[Iso[S, Tuple]]]`) with a
proper wildcard return type using `PIso[S, S, ? <: Tuple, ? <: Tuple]`.
Since `IsoFields.apply` is a `transparent inline` method, the compiler
still infers the precise tuple type at call sites. This avoids the unsafe
cast and prepares for potential stricter macro type checking in future
Scala versions.
The motivation is to prepare for future stricter checks in the Scala 3
compiler. The current implementation exploits a missing check to generate
an unsound cast.
Note: we use `PIso` (a trait) directly instead of the `Iso` type alias
(defined as `type Iso[S, A] = PIso[S, S, A, A]`) because Scala 3 cannot
reduce higher-kinded type aliases applied to wildcard arguments.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add fallback match arm and extension syntax test
Address review comments:
- Report a proper error message when the mirror expression doesn't match
the expected shape in IsoFieldsImpl.apply
- Add a test exercising the Iso.fields extension method on a value
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Reformat with scalafmt
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 1441106 commit 065f774
3 files changed
Lines changed: 19 additions & 11 deletions
File tree
Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | | - | |
| 19 | + | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
34 | 43 | | |
0 commit comments