-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to instantiate type variables in tryInsertImplicitOnQualifier
Fixes #13842 What happened in #13842 was that we were not hitting this case in `tryWiden`, which is a method in ApproximatingTypeMap that tries to dealias or widen before propagating a Range outwards: ```scala case info: SingletonType => // if H#x: y.type, then for any x in L..H, x.type =:= y.type, // hence we can replace with y.type under all variances reapply(info) ``` The actual info here was a TypeVar with a singleton type as lower bound. Instantiating the TypeVar produces a SingletonType and case applies. We cannot really instantiate TypeVars here since this is very low-level code. For instance we might be in a state where the instantiation is provisional and the TyperState is thrown away. But AsSeenFrom results are cached so we'd have the wrong type in the caches. What we do instead is add an additional case in `tryInsertImplicitOnQualifier` which is the last resort when an application fails. Here, if we can instantiate some type variables in the qualifier, we try again.
- Loading branch information
Showing
4 changed files
with
53 additions
and
16 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,14 @@ | ||
class Parent { class E } | ||
|
||
object ChildA extends Parent | ||
|
||
object ChildB extends Parent | ||
|
||
class Printer[C <: Parent](val child: C): | ||
def print22(e: child.E): String = "" | ||
|
||
def test = | ||
Printer(ChildA).print22(new ChildA.E) // does not work | ||
|
||
//Printer[ChildA.type](ChildA).print22(new ChildA.E) // works | ||
//val p = Printer(ChildA); p.print22(new ChildA.E) // works |