forked from scala/scala3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backport] Relax avoidance checks more for match type reduction
This backports scala#15036 which fixes a regression introduced in 3.1.2.
- Loading branch information
Showing
4 changed files
with
57 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import scala.compiletime.ops.int.* | ||
|
||
final class Label (val getLabel: String) | ||
|
||
trait ShapelessPolyfill { | ||
|
||
type Represented[R] = R match { | ||
case IndexedSeq[a] => a | ||
} | ||
|
||
type TupleSized[R, A, N <: Int] <: Tuple = N match { | ||
case 0 => EmptyTuple | ||
case S[n] => A *: TupleSized[R, A, n] | ||
} | ||
|
||
extension [R, A, N <: Int] (s: TupleSized[R, A, N]) { | ||
def unsized: IndexedSeq[A] = s.productIterator.toIndexedSeq.asInstanceOf[IndexedSeq[A]] | ||
} | ||
|
||
type Nat = Int | ||
|
||
type Sized[Repr, L <: Nat] = TupleSized[Repr, Represented[Repr], L] | ||
|
||
object Sized { | ||
def apply[A](a1: A): Sized[IndexedSeq[A], 1] = Tuple1(a1) | ||
} | ||
} | ||
object poly extends ShapelessPolyfill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import poly.* | ||
|
||
def failing: Tuple1[Label] = Sized(new Label("foo")) |