Skip to content

Commit 5672999

Browse files
Merge pull request #11030 from dotty-staging/fix-#7592
Add regression test
2 parents 3b60a7a + e734354 commit 5672999

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
3636
compileFilesInDir("tests/bench", defaultOptions),
3737
compileFilesInDir("tests/pos-macros", defaultOptions),
3838
compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Xsemanticdb")),
39+
compileDir("tests/pos-special/i7592", defaultOptions.and("-Yretain-trees")),
3940
).checkCompile()
4041
}
4142

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import scala.quoted._
2+
3+
def compileImpl[T](expr : Expr[T])(using Quotes) : Expr[T] = {
4+
import quotes.reflect._
5+
6+
def proc(term : Term): Term = {
7+
term match {
8+
case Inlined(call, bindings, body) => Inlined(call, bindings, proc(body))
9+
case l : Literal => l
10+
case Block(statements, expr) =>
11+
proc(expr) // FIXME: very wrong
12+
case s : (Select|Ident) => {
13+
if( s.symbol.isDefDef ) {
14+
s.symbol.tree match {
15+
case DefDef(name, typeParams, params, returnTp, Some(rhs)) => proc(rhs)
16+
}
17+
} else {
18+
???
19+
}
20+
}
21+
}
22+
}
23+
24+
proc(expr.asTerm).asExpr.asInstanceOf[Expr[T]]
25+
}
26+
27+
inline def compile[T](expr : =>T) : T =
28+
${ compileImpl('{ expr }) }

tests/pos-special/i7592/Test_2.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def return1 = 1
2+
3+
def testReturn1 = {
4+
assert(1 == compile(return1))
5+
}

0 commit comments

Comments
 (0)