Skip to content

Commit 100bdeb

Browse files
committed
Address remaining review comments
1 parent 79bfff4 commit 100bdeb

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
138138
* everytime we compare components of the previous pair of types.
139139
* This type is used for capture conversion in `isSubArgs`.
140140
*/
141-
private [this] var leftRoot: Type = null
141+
private [this] var leftRoot: Type = _
142142

143143
protected def isSubType(tp1: Type, tp2: Type, a: ApproxState): Boolean = {
144144
val savedApprox = approx

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3623,7 +3623,7 @@ object Types {
36233623
* and fill in their infos with types that refers to the skolem types recursively.
36243624
* This is used in `captureWildcards` in `Typer`.
36253625
*/
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 {
36273627
override def underlying(implicit ctx: Context): Type = info
36283628
def derivedSkolemType(info: Type)(implicit ctx: Context): SkolemType =
36293629
if (info eq this.info) this else SkolemType(info)

tests/pos/capture.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
// Convert `t` to `t.cast[C[$j.CAP]]` where `$j` is a skolem of type `TypeBox[Nothing, Any`]
1515
// (or more generally, `TypeBox[L, U]`) wgere `L` and `U` are the bounds of the wildcard).
1616
//
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.
1820
class Test {
1921

2022
abstract class Liftable[T]
@@ -31,5 +33,5 @@ class Test {
3133

3234
runtimeClass.toExpr(ClassIsLiftable) // OK for skolemization-as-a-whole and skolemization-of-each-param
3335

34-
runtimeClass.toExpr // only works with skolemization-of-each-param
36+
runtimeClass.toExpr // only works with skolemization-of-each-param, also works in scalac.
3537
}

0 commit comments

Comments
 (0)