Skip to content
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

Add recheck phase #12971

Merged
merged 7 commits into from
Aug 17, 2021
Merged

Add recheck phase #12971

merged 7 commits into from
Aug 17, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 28, 2021

Add a phase for recomputing and rechecking all types in a typed Scala program. This is useful for two reasons:

  • It gives us additional explanation and validation what constitutes a well-typed Scala 3 program. Recheck has less than 300 lines of code, which is a lot less than Typer and associated files.
  • It can be used as a basis for phases that refine the original types with new kinds of types and new rules.

Based on #12938

@@ -1161,6 +1160,37 @@ class Typer extends Namer
}
}

/** The parameter type for a parameter in a lambda that does
* not have an explicit type given, and where the type is not known from the context.
* In this case the paranmeter type needs to be inferred the "target type" T known
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling

Suggested change
* In this case the paranmeter type needs to be inferred the "target type" T known
* In this case the parameter type needs to be inferred from the "target type" T known

@dwijnand
Copy link
Member

dwijnand commented Jul 5, 2021

#12938 now merged

@odersky
Copy link
Contributor Author

odersky commented Aug 8, 2021

Squashed to one commit and rebased to master

… program. This is useful for two reasons:

 = It gives us additional explanation and validation what constitutes a well-typed Scala 3 program. Recheck has less than 300 lines of code, which is a lot less than Typer and associated files.
 - It can be used as a basis for phases that refine the original types with new kinds of types and new rules.
@odersky
Copy link
Contributor Author

odersky commented Aug 8, 2021

@olhotak Wpuld you be interested in reviewing this? I think it is ready to merge.


def run(using Context): Unit =
val unit = ctx.compilationUnit
//println(i"recheck types of $unit")
Copy link
Contributor

Choose a reason for hiding this comment

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

stray (commented) println

def recheckBind(tree: Bind, pt: Type)(using Context): Type = tree match
case Bind(name, body) =>
enterDef(tree)
val bodyType = recheck(body, pt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional that bodyType is unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. But I am not completely sure how to handle that. Generally, Binds will be gone by the time the rechecker is run, except for type binds.

compiler/src/dotty/tools/dotc/transform/Recheck.scala Outdated Show resolved Hide resolved
compiler/src/dotty/tools/dotc/transform/Recheck.scala Outdated Show resolved Hide resolved
compiler/test/dotc/pos-test-recheck.exludes Outdated Show resolved Hide resolved
This is necessary since not all constant folded terms are converted to literals.
The conversion does not happen if one of the operands is impure. A test case
is run/final-field.scala
Detected when fixing the conforms check
  - rename `exludes` --> `excludes`
  - fix comments
Treat a SolemType(T) as a supertype (as well as a subtype) of T.
* - 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.

@olhotak
Copy link
Contributor

olhotak commented Aug 13, 2021

LGTM now.

@odersky odersky merged commit 12cb6c5 into scala:master Aug 17, 2021
@odersky odersky deleted the add-rechecker branch August 17, 2021 10:38
odersky added a commit to dotty-staging/dotty that referenced this pull request Aug 17, 2021
bishabosha added a commit that referenced this pull request Aug 17, 2021
Revert "Merge pull request #12971 from dotty-staging/add-rechecker"
odersky added a commit to dotty-staging/dotty that referenced this pull request Sep 1, 2021
odersky added a commit that referenced this pull request Sep 4, 2021
odersky added a commit to dotty-staging/dotty that referenced this pull request Sep 24, 2021
odersky added a commit that referenced this pull request Sep 24, 2021
odersky added a commit to dotty-staging/dotty that referenced this pull request Oct 2, 2021
odersky added a commit to dotty-staging/dotty that referenced this pull request Dec 11, 2021
odersky added a commit that referenced this pull request Jan 21, 2022
odersky added a commit that referenced this pull request Jan 25, 2022
odersky added a commit that referenced this pull request Jan 26, 2022
odersky added a commit that referenced this pull request Jan 28, 2022
odersky added a commit that referenced this pull request Feb 9, 2022
odersky added a commit that referenced this pull request Feb 25, 2022
odersky added a commit that referenced this pull request Mar 6, 2022
odersky added a commit that referenced this pull request Mar 26, 2022
olsdavis pushed a commit to olsdavis/dotty that referenced this pull request Apr 4, 2022
odersky added a commit that referenced this pull request Apr 28, 2022
odersky added a commit that referenced this pull request May 18, 2022
odersky added a commit that referenced this pull request May 29, 2022
odersky added a commit that referenced this pull request Jul 26, 2022
odersky added a commit that referenced this pull request Jul 26, 2022
odersky added a commit that referenced this pull request Jul 26, 2022
odersky added a commit that referenced this pull request Aug 8, 2022
odersky added a commit that referenced this pull request Aug 17, 2022
odersky added a commit to dotty-staging/dotty that referenced this pull request Aug 29, 2022
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants