Skip to content

Commit 5670a3f

Browse files
committed
Also run PostTyper and Inliner from completime.typechecks
For the moment we specialize this to PostTyper and Inliner. We could run more phases (e.g. all phases up to erasure) but that would require a different infrastructure where we encapsulate the parsed string in a compilation unit.
1 parent 7ea74c0 commit 5670a3f

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

compiler/src/dotty/tools/dotc/transform/Inlining.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Inlining extends MacroTransform {
6767
case _ =>
6868
}
6969

70-
protected def newTransformer(using Context): Transformer = new Transformer {
70+
def newTransformer(using Context): Transformer = new Transformer {
7171
override def transform(tree: tpd.Tree)(using Context): tpd.Tree =
7272
new InliningTreeMap().transform(tree)
7373
}

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
7070

7171
override def transformPhase(using Context): Phase = thisPhase.next
7272

73-
protected def newTransformer(using Context): Transformer =
73+
def newTransformer(using Context): Transformer =
7474
new PostTyperTransformer
7575

7676
val superAcc: SuperAccessors = new SuperAccessors(thisPhase)

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import ErrorReporting.errorTree
2525
import dotty.tools.dotc.util.{SimpleIdentityMap, SimpleIdentitySet, EqHashMap, SourceFile, SourcePosition, SrcPos}
2626
import dotty.tools.dotc.parsing.Parsers.Parser
2727
import Nullables._
28+
import transform.{PostTyper, Inlining}
2829

2930
import collection.mutable
3031
import reporting.trace
@@ -318,7 +319,11 @@ object Inliner {
318319
val parseErrors = ctx2.reporter.allErrors.toList
319320
res ++= parseErrors.map(e => ErrorKind.Parser -> e)
320321
if res.isEmpty then
321-
ctx2.typer.typed(tree2)(using ctx2)
322+
val tree3 = ctx2.typer.typed(tree2)(using ctx2)
323+
val postTyper = ctx.base.postTyperPhase.asInstanceOf[PostTyper]
324+
val tree4 = postTyper.newTransformer.transform(tree3)(using ctx2.withPhase(postTyper))
325+
val inlining = ctx.base.inliningPhase.asInstanceOf[Inlining]
326+
inlining.newTransformer.transform(tree4)(using ctx2.withPhase(inlining))
322327
val typerErrors = ctx2.reporter.allErrors.filterNot(parseErrors.contains)
323328
res ++= typerErrors.map(e => ErrorKind.Typer -> e)
324329
res.toList

tests/run-macros/i11630.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
inline def failme1() = compiletime.error("fail")
2+
transparent inline def failme2() = compiletime.error("fail")
3+
4+
@main def Test =
5+
assert(!compiletime.testing.typeChecks("failme1()"))
6+
assert(!compiletime.testing.typeChecks("failme2()"))
7+
assert(!compiletime.testing.typeChecks("a b c"))
8+
assert(!compiletime.testing.typeChecks("true: Int"))
9+

0 commit comments

Comments
 (0)