Skip to content

Commit ced25db

Browse files
committed
Add test case and fix interpreted TypeApply
1 parent 3ac8fd8 commit ced25db

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

compiler/src/dotty/tools/dotc/interpreter/Interpreter.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ class Interpreter(implicit ctx: Context) {
6363
* If some error is encountered while interpreting a ctx.error is emitted and a StopInterpretation is thrown.
6464
*/
6565
private def interpretTreeImpl(tree: Tree, env: Env): Object = {
66-
ctx.debuglog(
67-
s"""Interpreting:
68-
|${tree.show}
69-
|$env
70-
""".stripMargin)
66+
// println(s"Interpreting:\n${tree.show}\n$env\n")
7167

7268
implicit val pos: Position = tree.pos
7369

@@ -114,6 +110,9 @@ class Interpreter(implicit ctx: Context) {
114110
val env2 = bindings.foldLeft(env)((acc, x) => interpretStat(x, acc))
115111
interpretTreeImpl(expansion, env2)
116112

113+
case TypeApply(fn, _) =>
114+
interpretTreeImpl(fn, env)
115+
117116
case Typed(expr, _) =>
118117
interpretTreeImpl(expr, env)
119118

@@ -129,7 +128,7 @@ class Interpreter(implicit ctx: Context) {
129128
case _ =>
130129
// TODO Add more precise descriptions of why it could not be interpreted.
131130
// This should be done after the full interpreter is implemented.
132-
throw new StopInterpretation(s"Could not interpret ${tree.show}. Consider extracting logic into a helper def.", tree.pos)
131+
throw new StopInterpretation(s"Could not interpret ${tree.show}. Consider extracting logic into a helper def.\n$tree\n", tree.pos)
133132
}
134133
}
135134

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ object Splicer {
1616
*/
1717
def splice(tree: Tree)(implicit ctx: Context): Tree = tree match {
1818
case Quoted(quotedTree) => quotedTree
19-
case tree: RefTree => reflectiveSplice(tree)
20-
case tree: Apply => reflectiveSplice(tree)
21-
case tree: Inlined => reflectiveSplice(tree)
22-
case tree: Block => reflectiveSplice(tree)
19+
case _ => reflectiveSplice(tree)
2320
}
2421

2522
/** Splice the Tree for a Quoted expression which is constructed via a reflective call to the given method */

tests/pos/i4023b/Macro_1.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
object Macro {
3+
inline def ff[T](implicit t: Type[T]): Int = ~impl[T]
4+
def impl[T]: Expr[Int] = 4
5+
}

tests/pos/i4023b/Test_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
Macro.ff[Int]
3+
}

0 commit comments

Comments
 (0)