inlineExpr replaces the current expression with the inlined one, unless the location of the inlining happens within a presence test, e.g. has(a.b.c) -> inline alpha for a.b.c in which case an attempt is made to determine whether the inlined value can be presence or existence tested.
(ctx *OptimizerContext, prev ast.NavigableExpr, inlined ast.Expr, inlinedType *Type)
| 134 | // happens within a presence test, e.g. has(a.b.c) -> inline alpha for a.b.c in which case an attempt is |
| 135 | // made to determine whether the inlined value can be presence or existence tested. |
| 136 | func (opt *inliningOptimizer) inlineExpr(ctx *OptimizerContext, prev ast.NavigableExpr, inlined ast.Expr, inlinedType *Type) { |
| 137 | switch prev.Kind() { |
| 138 | case ast.SelectKind: |
| 139 | sel := prev.AsSelect() |
| 140 | if !sel.IsTestOnly() { |
| 141 | ctx.UpdateExpr(prev, inlined) |
| 142 | return |
| 143 | } |
| 144 | opt.rewritePresenceExpr(ctx, prev, inlined, inlinedType) |
| 145 | default: |
| 146 | ctx.UpdateExpr(prev, inlined) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // rewritePresenceExpr converts the inlined expression, when it occurs within a has() macro, to type-safe |
| 151 | // expression appropriate for the inlined type, if possible. |
no test coverage detected