Skip to content

Add recheck phase #12971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ object Phases {
/** If set, implicit search is enabled */
def allowsImplicitSearch: Boolean = false

/** If set equate Skolem types with underlying types */
def widenSkolems: Boolean = false

/** List of names of phases that should precede this phase */
def runsAfter: Set[String] = Set.empty

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
false
}
compareClassInfo
case tp2: SkolemType =>
ctx.phase.widenSkolems && recur(tp1, tp2.info) || fourthTry
case _ =>
fourthTry
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/Recheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
// TODO: investigate what goes wrong we Ycheck directly after rechecking.
// One failing test is pos/i583a.scala

override def widenSkolems = true

def run(using Context): Unit =
newRechecker().checkUnit(ctx.compilationUnit)

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

def checkUnit(unit: CompilationUnit)(using Context): Unit =
Expand Down
5 changes: 0 additions & 5 deletions compiler/test/dotc/pos-test-recheck.excludes
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Cannot compensate dealiasing due to false result dependency
i6635a.scala
i6682a.scala

# Cannot handle closures with skolem types
i6199b.scala
i6199c.scala
i11247.scala
8 changes: 5 additions & 3 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ class CompilationTests {
).checkCompile()


/** The purpose of this test is three-fold, being able to compile dotty
* bootstrapped, and making sure that TASTY can link against a compiled
* version of Dotty, and compiling the compiler using the SemanticDB generation
/** This test serves several purposes:
* - being able to compile dotty bootstrapped,
* - making sure that TASTY can link against a compiled version of Dotty,
* - compiling the compiler using the SemanticDB generation
* - compiling the compiler under -Yrecheck mode.
Copy link
Member

@smarter smarter Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can -Yrecheck be thought of as a more extensive -Ycheck or do they end up checking different things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite different things. -Yrecheck is only for testing special recheck phases. Right now there is only one such phase planned, and that is the capture checker. But others might follow.

*/
@Test def tastyBootstrap: Unit = {
implicit val testGroup: TestGroup = TestGroup("tastyBootstrap/tests")
Expand Down