Skip to content

Commit 990ebf3

Browse files
committed
Remove the -rewrite option for typechecks methods in Quotes
1 parent 5e83606 commit 990ebf3

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,13 @@ object Inlines:
342342
if Inlines.isInlineable(codeArg1.symbol) then stripTyped(Inlines.inlineCall(codeArg1))
343343
else codeArg1
344344

345+
// We should not be rewriting tested strings
346+
val noRewriteSettings = ctx.base.settings.rewrite.update(None)
347+
345348
ConstFold(underlyingCodeArg).tpe.widenTermRefExpr match {
346349
case ConstantType(Constant(code: String)) =>
347350
val source2 = SourceFile.virtual("tasty-reflect", code)
348-
inContext(ctx.fresh.setNewTyperState().setTyper(new Typer(ctx.nestingLevel + 1)).setSource(source2)) {
351+
inContext(ctx.fresh.setSettings(noRewriteSettings).setNewTyperState().setTyper(new Typer(ctx.nestingLevel + 1)).setSource(source2)) {
349352
val tree2 = new Parser(source2).block()
350353
if ctx.reporter.allErrors.nonEmpty then
351354
ctx.reporter.allErrors.map((ErrorKind.Parser, _))

compiler/test/dotc/pos-test-pickling.blacklist

+3
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ parsercombinators-new-syntax.scala
135135
hylolib-deferred-given
136136
hylolib-cb
137137
hylolib
138+
139+
# typecheckErrors method unpickling
140+
i21415.scala

compiler/test/dotc/run-test-pickling.blacklist

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ tuple-zip.scala
2727
tuples1.scala
2828
tuples1a.scala
2929
tuples1b.scala
30-
typeCheckErrors.scala
3130
typeclass-derivation-doc-example.scala
3231
typeclass-derivation1.scala
3332
typeclass-derivation2.scala
@@ -47,3 +46,6 @@ trait-static-forwarder
4746
i17255
4847
named-tuples-strawman-2.scala
4948

49+
# typecheckErrors method unpickling
50+
typeCheckErrors.scala
51+

tests/pos/i21415.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//> using options -rewrite -source:3.4-migration
2+
import scala.compiletime.testing.typeCheckErrors
3+
4+
def foo(arg: Int): Unit = ???
5+
6+
@main def Test =
7+
typeCheckErrors("Seq.empty[Int].foreach(foo.apply _)")
8+
typeCheckErrors("Seq.empty[Int].foreach(foo.apply _)")

0 commit comments

Comments
 (0)