-
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.
Normalize types before collecting parts determining implicit scope
This is necessary to ensure the implicit scope is consistent when involving match types, since they may or may not have been reduced before implicit search. We can for example get different results when loading from tasty than when in the same run. Fixes #20071
- Loading branch information
1 parent
9a5b9b4
commit 90c3fbd
Showing
3 changed files
with
35 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
trait Scope | ||
object Scope: | ||
given i: Int = ??? | ||
|
||
type ReferencesScope[S] >: Int <: Int | ||
|
||
type ScopeToInt[Why] = Why match | ||
case Scope => Int | ||
|
||
def foo[T](using d: ReferencesScope[T]): Any = ??? | ||
|
||
def bar[T](using d: ScopeToInt[T]): Any = ??? | ||
|
||
def test: Unit = | ||
foo[Scope] // ok | ||
bar[Scope] // error | ||
|
||
import Scope.i | ||
bar[Scope] // ok | ||
|
||
/* | ||
Before the changes: | ||
`ScopeToInt[Scope]` may or may not be reduced before implicit search, | ||
thereby impacting the scope considered for the search. `Scope.i` is included | ||
iff `Scope` still appears in the type, which is the case only before reduction. | ||
In contrast, `ReferencesScope[Scope]` is ok since it will never lose the anchor. | ||
*/ |
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