Skip to content

Commit 03a7bd8

Browse files
committed
Loosen skolem comparisons when rechecking
Treat a SolemType(T) as a supertype (as well as a subtype) of T.
1 parent 2b88f1c commit 03a7bd8

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ object Phases {
295295
/** If set, implicit search is enabled */
296296
def allowsImplicitSearch: Boolean = false
297297

298+
/** If set equate Skolem types with underlying types */
299+
def widenSkolems: Boolean = false
300+
298301
/** List of names of phases that should precede this phase */
299302
def runsAfter: Set[String] = Set.empty
300303

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
745745
false
746746
}
747747
compareClassInfo
748+
case tp2: SkolemType =>
749+
ctx.phase.widenSkolems && recur(tp1, tp2.info) || fourthTry
748750
case _ =>
749751
fourthTry
750752
}

compiler/src/dotty/tools/dotc/transform/Recheck.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
3333
// TODO: investigate what goes wrong we Ycheck directly after rechecking.
3434
// One failing test is pos/i583a.scala
3535

36+
override def widenSkolems = true
37+
3638
def run(using Context): Unit =
3739
newRechecker().checkUnit(ctx.compilationUnit)
3840

@@ -315,6 +317,7 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
315317
|| expected.isRepeatedParam
316318
&& actual <:< expected.translateFromRepeated(toArray = tree.tpe.isRef(defn.ArrayClass))
317319
if !isCompatible then
320+
println(i"err at ${ctx.phase}")
318321
err.typeMismatch(tree.withType(tpe), pt)
319322

320323
def checkUnit(unit: CompilationUnit)(using Context): Unit =
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
# Cannot compensate dealiasing due to false result dependency
22
i6635a.scala
33
i6682a.scala
4-
5-
# Cannot handle closures with skolem types
6-
i6199b.scala
7-
i6199c.scala
8-
i11247.scala

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ class CompilationTests {
229229
).checkCompile()
230230

231231

232-
/** The purpose of this test is three-fold, being able to compile dotty
233-
* bootstrapped, and making sure that TASTY can link against a compiled
234-
* version of Dotty, and compiling the compiler using the SemanticDB generation
232+
/** This test serves several purposes:
233+
* - being able to compile dotty bootstrapped,
234+
* - making sure that TASTY can link against a compiled version of Dotty,
235+
* - compiling the compiler using the SemanticDB generation
236+
* - compiling the compiler under -Yrecheck mode.
235237
*/
236238
@Test def tastyBootstrap: Unit = {
237239
implicit val testGroup: TestGroup = TestGroup("tastyBootstrap/tests")

0 commit comments

Comments
 (0)