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

Remove the -rewrite option for typechecks methods in Quotes #21547

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ object Settings:
values(idx) = x
changed.add(idx)
this

def reinitializedCopy(): SettingsState =
SettingsState(values.toSeq, changed.toSet)

end SettingsState

case class ArgsSummary(
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/inlines/Inlines.scala
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,13 @@ object Inlines:
if Inlines.isInlineable(codeArg1.symbol) then stripTyped(Inlines.inlineCall(codeArg1))
else codeArg1

// We should not be rewriting tested strings
val noRewriteSettings = ctx.settings.rewrite.updateIn(ctx.settingsState.reinitializedCopy(), None)

ConstFold(underlyingCodeArg).tpe.widenTermRefExpr match {
case ConstantType(Constant(code: String)) =>
val source2 = SourceFile.virtual("tasty-reflect", code)
inContext(ctx.fresh.setNewTyperState().setTyper(new Typer(ctx.nestingLevel + 1)).setSource(source2)) {
inContext(ctx.fresh.setSettings(noRewriteSettings).setNewTyperState().setTyper(new Typer(ctx.nestingLevel + 1)).setSource(source2)) {
val tree2 = new Parser(source2).block()
if ctx.reporter.allErrors.nonEmpty then
ctx.reporter.allErrors.map((ErrorKind.Parser, _))
Expand Down
3 changes: 3 additions & 0 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ parsercombinators-new-syntax.scala
hylolib-deferred-given
hylolib-cb
hylolib

# typecheckErrors method unpickling
i21415.scala
4 changes: 3 additions & 1 deletion compiler/test/dotc/run-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ tuple-zip.scala
tuples1.scala
tuples1a.scala
tuples1b.scala
typeCheckErrors.scala
typeclass-derivation-doc-example.scala
typeclass-derivation1.scala
typeclass-derivation2.scala
Expand All @@ -47,3 +46,6 @@ trait-static-forwarder
i17255
named-tuples-strawman-2.scala

# typecheckErrors method unpickling
typeCheckErrors.scala

8 changes: 8 additions & 0 deletions tests/pos/i21415.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//> using options -rewrite -source:3.4-migration
import scala.compiletime.testing.typeCheckErrors

def foo(arg: Int): Unit = ???

@main def Test =
typeCheckErrors("Seq.empty[Int].foreach(foo.apply _)")
typeCheckErrors("Seq.empty[Int].foreach(foo.apply _)")
Loading