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 5, 2024
1 parent 5e83606 commit 990ebf3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
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.base.settings.rewrite.update(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 990ebf3

Please sign in to comment.