Skip to content

Commit

Permalink
Remove the -rewrite option for typechecks methods in Quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jchyb committed Sep 10, 2024
1 parent 5e83606 commit 3025bfb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
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 _)")

0 comments on commit 3025bfb

Please sign in to comment.