Skip to content

Commit 217d0e1

Browse files
nicolasstuckiWojciechMazur
authored andcommitted
Fix TypeTreeTypeTest to not match TypeBoundsTrees
Also see `TypeBoundsTreeTypeTest` in `QuotesImpl` and `Quotes` spec ``` * +- TypeTree ----+- Inferred * | +- ... * | ... * +- TypeBoundsTree ``` Fixes #19480 [Cherry-picked 00f11a3]
1 parent 9812065 commit 217d0e1

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
10841084

10851085
object TypeTreeTypeTest extends TypeTest[Tree, TypeTree]:
10861086
def unapply(x: Tree): Option[TypeTree & x.type] = x match
1087-
case x: (tpd.TypeBoundsTree & x.type) => None
1087+
case TypeBoundsTreeTypeTest(_) => None
10881088
case x: (tpd.Tree & x.type) if x.isType => Some(x)
10891089
case _ => None
10901090
end TypeTreeTypeTest

tests/pos-macros/i19480/Macro_1.scala

Lines changed: 11 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test = whatever
Lines changed: 11 additions & 0 deletions
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/i19480b/Test_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test = whatever

0 commit comments

Comments
 (0)