-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix higher-order unification incorrectly substituting tparams
When creating a fresh type lambda for the purpose of higher-order type inference, we incorrectly substituted references to type parameters before this commit. We want to construct: bodyArgs := otherArgs.take(d), T_0, ..., T_k-1 [T_0, ..., T_k-1] =>> otherTycon[bodyArgs] For this type to be valid, we need the bounds of `T_i` to be the bounds of the (d+i) type parameter of `otherTycon` after substituting references to each type parameter of `otherTycon` by the corresponding argument in `bodyArgs`. The previous implementation incorrectly substituted only the last `k` type parameters, this was not enough for correctness. It could also lead to a crash because it called `integrate` which implicitly assumes it is passed a full list of type parameters (this is now documented). Fixes #15983.
- Loading branch information
Showing
5 changed files
with
51 additions
and
8 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,11 @@ | ||
class OtherC[A, B, C <: B] | ||
|
||
trait crash { | ||
type OtherT[A, B, C <: B] | ||
|
||
def indexK[F[_]]: F[Any] = ??? | ||
|
||
def res: OtherT[Any, Any, Any] = indexK | ||
|
||
def res2: OtherC[Any, Any, Any] = indexK | ||
} |
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,11 @@ | ||
class OtherC[A, B, C <: B, D <: C] | ||
|
||
trait crash { | ||
type OtherT[A, B, C <: B, D <: C] | ||
|
||
def indexK[F[X, Y <: X]]: F[Any, Any] = ??? | ||
|
||
def res: OtherT[Any, Any, Any, Any] = indexK | ||
|
||
def res2: OtherC[Any, Any, Any, Any] = indexK | ||
} |