@@ -161,15 +161,15 @@ different directions here for `f` and `x`. The reference to `f` is
161
161
legal because it is quoted, then spliced, whereas the reference to ` x `
162
162
is legal because it is spliced, then quoted.
163
163
164
- ### Types and the PCP
164
+ ### Lifting Types
165
165
166
- In principle, The phase consistency principle applies to types as well
167
- as for expressions. But it only acts on types that are used in higher levels.
168
- This might seem too restrictive. Indeed, the
169
- definition of ` reflect ` above is not phase correct since there is a
166
+ Types are not directly affected by the phase consistency principle.
167
+ It is possible to use types defined at any level in any other level.
168
+ But, if a type is used in a subsequent stage it will need to be lifted to a ` Type ` .
169
+ The resulting value of ` Type ` will be subject to PCP.
170
+ Indeed, the definition of ` reflect ` above uses ` T ` in the next stage, there is a
170
171
quote but no splice between the parameter binding of ` T ` and its
171
- usage. But the code can be made phase correct by adding a binding
172
- of a ` Type[T] ` tag:
172
+ usage. But the code can be rewritten by adding a binding of a ` Type[T] ` tag:
173
173
``` scala
174
174
def reflect [T , U ](f : Expr [T ] => Expr [U ])(given t : Type [T ]): Expr [T => U ] =
175
175
' { (x : $t) => $ { f(' x ) } }
@@ -178,8 +178,8 @@ In this version of `reflect`, the type of `x` is now the result of
178
178
splicing the ` Type ` value ` t ` . This operation _ is_ splice correct -- there
179
179
is one quote and one splice between the use of ` t ` and its definition.
180
180
181
- To avoid clutter, the Scala implementation tries to convert any phase-incorrect
182
- reference to a type ` T ` to a type-splice, by rewriting ` T ` to ` ${ summon[Type[T]] } ` .
181
+ To avoid clutter, the Scala implementation tries to convert any type
182
+ reference to a type ` T ` in subsequent phases to a type-splice, by rewriting ` T ` to ` ${ summon[Type[T]] } ` .
183
183
For instance, the user-level definition of ` reflect ` :
184
184
185
185
``` scala
0 commit comments