Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relax avoidance checks more for match type reduction
TypeParamRefs in match types do not have a corresponding TypeVar so they get assigned level Int.MaxValue by default, this means they can refer to variables at any level, but to avoid a crash in i14921 we also need the reverse direction (they can appear in the bounds of variables of any level), both direction should be safe because these constraints only exist during match type reduction (see `MatchType#reduced`). Fixes #14921.
- 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")) |