You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change improves the code generation of the contents of splices. In
the splicing phase, we have to find all types that are defined in the
quote but used in the splice. When there are type aliases, we can end up
with several `Type[T]` for the different aliases of `T`. By dealiasing
during the staging phase (just before splicing phase) we make sure that
the splicer phase will only generate one `Type[T]`.
By dealiasing we also optimize some situations where a type from outside
a quote is inserted in the quoted code and then used in one of its
splice through an alias. In this situation we can use the outer
`Type[T]` directly.
### Example
After staging the following code should get what is in the comments
```scala
import scala.quoted.*
def f[T](using t: Type[T])(using Quotes) =
'{
// @SplicedType type t$1 = t.Underlying
type T2 = T // type T2 = t$1
${
val t0: T = ???
val t1: T2 = ??? // val t1: T = ???
val tp1 = Type.of[T] // val tp1 = t
val tp2 = Type.of[T2] // val tp2 = t
'{
// @SplicedType type t$2 = t.Underlying
val t3: T = ??? // val t3: t$2 = ???
val t4: T2 = ??? // val t4: t$2 = ???
}
}
}
def g(using Quotes) =
'{
type U
type U2 = U
${
val u1: U = ???
val u2: U2 = ??? // val u2: U = ???
val tp1 = Type.of[U] // val tp1 = Type.of[U]
val tp2 = Type.of[U2] // val tp2 = Type.of[U]
'{
val u3: U = ???
val u4: U2 = ??? // val u4: U = ???
}
}
}
```
0 commit comments