File tree 3 files changed +6
-4
lines changed
compiler/src/dotty/tools/dotc/core
3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
138
138
* everytime we compare components of the previous pair of types.
139
139
* This type is used for capture conversion in `isSubArgs`.
140
140
*/
141
- private [this ] var leftRoot : Type = null
141
+ private [this ] var leftRoot : Type = _
142
142
143
143
protected def isSubType (tp1 : Type , tp2 : Type , a : ApproxState ): Boolean = {
144
144
val savedApprox = approx
Original file line number Diff line number Diff line change @@ -3623,7 +3623,7 @@ object Types {
3623
3623
* and fill in their infos with types that refers to the skolem types recursively.
3624
3624
* This is used in `captureWildcards` in `Typer`.
3625
3625
*/
3626
- case class SkolemType (var info : Type ) extends UncachedProxyType with ValueType with SingletonType {
3626
+ case class SkolemType (private [dotc] var info : Type ) extends UncachedProxyType with ValueType with SingletonType {
3627
3627
override def underlying (implicit ctx : Context ): Type = info
3628
3628
def derivedSkolemType (info : Type )(implicit ctx : Context ): SkolemType =
3629
3629
if (info eq this .info) this else SkolemType (info)
Original file line number Diff line number Diff line change 14
14
// Convert `t` to `t.cast[C[$j.CAP]]` where `$j` is a skolem of type `TypeBox[Nothing, Any`]
15
15
// (or more generally, `TypeBox[L, U]`) wgere `L` and `U` are the bounds of the wildcard).
16
16
//
17
- // skolemization-of-ewach-param is more robust since it is stable under widening.
17
+ // skolemization-of-each-param is more robust since it is stable under widening.
18
+ // By contrast, skolemization-as-a-whole risks losing capturing ability if the skolem
19
+ // type is widened in some context. This leads to the difference in behavior shown below.
18
20
class Test {
19
21
20
22
abstract class Liftable [T ]
@@ -31,5 +33,5 @@ class Test {
31
33
32
34
runtimeClass.toExpr(ClassIsLiftable ) // OK for skolemization-as-a-whole and skolemization-of-each-param
33
35
34
- runtimeClass.toExpr // only works with skolemization-of-each-param
36
+ runtimeClass.toExpr // only works with skolemization-of-each-param, also works in scalac.
35
37
}
You can’t perform that action at this time.
0 commit comments