@@ -68,7 +68,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
68
68
// TODO fill in
69
69
}
70
70
71
- /** Check bounds of AppliedTypeTrees and TypeApplys .
71
+ /** Check bounds of AppliedTypeTrees.
72
72
* Replace type trees with TypeTree nodes.
73
73
* Replace constant expressions with Literal nodes.
74
74
* Note: Demanding idempotency instead of purity in literalize is strictly speaking too loose.
@@ -97,29 +97,17 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
97
97
* Revisit this issue once we have implemented `inline`. Then we can demand
98
98
* purity of the prefix unless the selection goes to an inline val.
99
99
*/
100
- private def normalizeTree (tree : Tree )(implicit ctx : Context ): Tree = {
101
- def literalize (tp : Type ): Tree = tp.widenTermRefExpr match {
102
- case ConstantType (value) if isIdempotentExpr(tree) => Literal (value)
103
- case _ => tree
104
- }
105
- def norm (tree : Tree ) =
106
- if (tree.isType) TypeTree (tree.tpe).withPos(tree.pos)
107
- else literalize(tree.tpe)
108
- tree match {
109
- case tree : TypeTree =>
110
- tree
111
- case AppliedTypeTree (tycon, args) =>
112
- val tparams = tycon.tpe.typeSymbol.typeParams
113
- val bounds = tparams.map(tparam =>
114
- tparam.info.asSeenFrom(tycon.tpe.normalizedPrefix, tparam.owner.owner).bounds)
115
- Checking .checkBounds(args, bounds, _.substDealias(tparams, _))
116
- norm(tree)
117
- case TypeApply (fn, args) =>
118
- Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])
119
- norm(tree)
120
- case _ =>
121
- norm(tree)
122
- }
100
+ private def normalizeTree (tree : Tree )(implicit ctx : Context ): Tree = tree match {
101
+ case tree : TypeTree => tree
102
+ case _ =>
103
+ if (tree.isType) {
104
+ Checking .boundsChecker.traverse(tree)
105
+ TypeTree (tree.tpe).withPos(tree.pos)
106
+ }
107
+ else tree.tpe.widenTermRefExpr match {
108
+ case ConstantType (value) if isIdempotentExpr(tree) => Literal (value)
109
+ case _ => tree
110
+ }
123
111
}
124
112
125
113
class PostTyperTransformer extends Transformer {
@@ -161,10 +149,16 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
161
149
}
162
150
case tree : Select =>
163
151
transformSelect(paramFwd.adaptRef(tree), Nil )
164
- case tree @ TypeApply (sel : Select , args) =>
165
- val args1 = transform(args)
166
- val sel1 = transformSelect(sel, args1)
167
- if (superAcc.isProtectedAccessor(sel1)) sel1 else cpy.TypeApply (tree)(sel1, args1)
152
+ case tree @ TypeApply (fn, args) =>
153
+ Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])
154
+ fn match {
155
+ case sel : Select =>
156
+ val args1 = transform(args)
157
+ val sel1 = transformSelect(sel, args1)
158
+ if (superAcc.isProtectedAccessor(sel1)) sel1 else cpy.TypeApply (tree)(sel1, args1)
159
+ case _ =>
160
+ super .transform(tree)
161
+ }
168
162
case tree @ Assign (sel : Select , _) =>
169
163
superAcc.transformAssign(super .transform(tree))
170
164
case tree : Template =>
@@ -186,6 +180,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
186
180
val tree1 =
187
181
if (sym.isClass) tree
188
182
else {
183
+ Checking .boundsChecker.traverse(tree.rhs)
189
184
cpy.TypeDef (tree)(rhs = TypeTree (tree.symbol.info))
190
185
}
191
186
super .transform(tree1)
0 commit comments