Skip to content

Commit 4c3ebdf

Browse files
committed
Fix TypeTreeTypeTest to not match TypeBoundsTrees
Also see `TypeBoundsTreeTypeTest` in `QuotesImpl` and `Quotes` spec ``` * +- TypeTree ----+- Inferred * | +- ... * | ... * +- TypeBoundsTree ``` Fixes #19480
1 parent e64a5a5 commit 4c3ebdf

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
11061106
object TypeTreeTypeTest extends TypeTest[Tree, TypeTree]:
11071107
def unapply(x: Tree): Option[TypeTree & x.type] = x match
11081108
case x: (tpd.TypeBoundsTree & x.type) => None
1109-
case x: (tpd.Tree & x.type) if x.isType => Some(x)
1109+
case x: (tpd.Tree & x.type) if x.isType =>
1110+
x.tpe match
1111+
case tpe: Types.TypeBounds => None
1112+
case _ => Some(x)
11101113
case _ => None
11111114
end TypeTreeTypeTest
11121115

tests/pos-macros/i19480/Macro_1.scala

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted.*
2+
3+
inline def whatever: Int = ${whateverImpl}
4+
5+
def whateverImpl(using Quotes): Expr[Int] = {
6+
import quotes.reflect.*
7+
val t = '{class K[T]}.asTerm
8+
object mapper extends TreeMap
9+
mapper.transformTree(t)(Symbol.spliceOwner)
10+
'{42}
11+
}

tests/pos-macros/i19480/Test_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test = whatever

0 commit comments

Comments
 (0)