@@ -154,21 +154,24 @@ object Potentials {
154
154
155
155
extension (pot : Potential ) def toPots : Potentials = Potentials .empty + pot
156
156
157
- extension (ps : Potentials ) def select (symbol : Symbol , source : Tree )(using Context ): Summary =
158
- ps.foldLeft(Summary .empty) { case (Summary (pots, effs) , pot) =>
157
+ extension (ps : Potentials ) def select (symbol : Symbol , source : Tree , selectEffect : Boolean = true )(using Context ): Summary =
158
+ ps.foldLeft(Summary .empty) { case (summary , pot) =>
159
159
// max potential length
160
160
// TODO: it can be specified on a project basis via compiler options
161
161
if (pot.size > 2 )
162
162
summary + Promote (pot)(pot.source)
163
163
else if (symbol.isConstructor)
164
- Summary (pots + pot, effs + MethodCall (pot, symbol)(source))
164
+ val res = summary + pot
165
+ if selectEffect then res + MethodCall (pot, symbol)(source)
166
+ else res
165
167
else if (symbol.isOneOf(Flags .Method | Flags .Lazy ))
166
- Summary (
167
- pots + MethodReturn (pot, symbol)(source),
168
- effs + MethodCall (pot, symbol)(source)
169
- )
168
+ val res = summary + MethodReturn (pot, symbol)(source)
169
+ if selectEffect then res + MethodCall (pot, symbol)(source)
170
+ else res
170
171
else
171
- Summary (pots + FieldReturn (pot, symbol)(source), effs + FieldAccess (pot, symbol)(source))
172
+ val res = summary + FieldReturn (pot, symbol)(source)
173
+ if selectEffect then res + FieldAccess (pot, symbol)(source)
174
+ else res
172
175
}
173
176
174
177
extension (ps : Potentials ) def promote (source : Tree ): Effects = ps.map(Promote (_)(source))
0 commit comments