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