Skip to content

Commit 56b3834

Browse files
committed
Fix StatementTypeTest
Now it trivially covers all: Import, Export, Definition, Term Previously we missed Import/Export and the optimized version of term testing was incomplete.
1 parent a9120ca commit 56b3834

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
186186

187187
object StatementTypeTest extends TypeTest[Tree, Statement]:
188188
def unapply(x: Tree): Option[Statement & x.type] = x match
189-
case _: tpd.PatternTree => None
190-
case _ =>
191-
if x.isTerm then TermTypeTest.unapply(x)
192-
else DefinitionTypeTest.unapply(x)
189+
case TermTypeTest(x: x.type) => Some(x)
190+
case DefinitionTypeTest(x: x.type) => Some(x)
191+
case ImportTypeTest(x: x.type) => Some(x)
192+
case ExportTypeTest(x: x.type) => Some(x)
193+
case _ => None
193194
end StatementTypeTest
194195

195196
type Definition = tpd.MemberDef

0 commit comments

Comments
 (0)