forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify: Drop mapping tparams to tvars
Mapping type params back to type vars is dangerous for match types because it can lead to one use-site's type var being cached as the reduction of the match type in a match alias defintion. It looks like mapping type parameters to type vars is only important when getting the instance type of a type parameter, because the bounds could make references to other parameters, including as type arguments. So, as long as we map then, we can drop this mapping from general simplification. There is, however, something going on with capture checking, which I documented, but perhaps it's due to some underlying bug. The situation occurs because boxed A *: T does seem to match case x *: _. So I kept the fully-defined forcing and normalization case from simplify.
- Loading branch information
Showing
8 changed files
with
41 additions
and
20 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
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,7 @@ | ||
type MT[T, M] = M match { case VAL => T } | ||
|
||
class Foo[A] | ||
object Foo: | ||
given inst[X, Y <: MT[X, VAL]]: Foo[Y] = new Foo[Y] | ||
|
||
trait VAL |
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,4 @@ | ||
class Test: | ||
def test: Unit = | ||
summon[Foo[Int]] | ||
summon[Foo[Long]] |
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,7 @@ | ||
trait DFBits[W <: Int] | ||
|
||
trait Candidate[R]: | ||
type OutW <: Int | ||
object Candidate: | ||
given [W <: Int, R <: Foo[DFBits[W], VAL]]: Candidate[R] with | ||
type OutW = W |
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,4 @@ | ||
trait VAL | ||
|
||
type Foo[T, M] = M match | ||
case VAL => T |
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,5 @@ | ||
def baz[L](lhs: L)(using icL: Candidate[L]): DFBits[Int] = ??? | ||
object Test: | ||
val x: DFBits[8] = ??? | ||
val z: DFBits[Int] = baz(x) | ||
summon[Candidate[z.type]] |