@@ -155,23 +155,31 @@ 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 , selectEffect : Boolean = true )(using Context ): Summary =
158
+ /** Selection on a set of potentials
159
+ *
160
+ * @param ignoreSelectEffect Where selection effects should be ignored
161
+ *
162
+ * During expansion of potentials, we ignore select effects and only care
163
+ * about promotion effects. This is because the selection effects have
164
+ * already been checked.
165
+ */
166
+ extension (ps : Potentials ) def select (symbol : Symbol , source : Tree , ignoreSelectEffect : Boolean = true )(using Context ): Summary =
159
167
ps.foldLeft(Summary .empty) { case (summary, pot) =>
160
168
// max potential length
161
169
// TODO: it can be specified on a project basis via compiler options
162
170
if (pot.size > 2 )
163
171
summary + Promote (pot)(pot.source)
164
172
else if (symbol.isConstructor)
165
173
val res = summary + pot
166
- if selectEffect then res + MethodCall (pot, symbol)(source)
174
+ if ignoreSelectEffect then res + MethodCall (pot, symbol)(source)
167
175
else res
168
176
else if (symbol.isOneOf(Flags .Method | Flags .Lazy ))
169
177
val res = summary + MethodReturn (pot, symbol)(source)
170
- if selectEffect then res + MethodCall (pot, symbol)(source)
178
+ if ignoreSelectEffect then res + MethodCall (pot, symbol)(source)
171
179
else res
172
180
else
173
181
val res = summary + FieldReturn (pot, symbol)(source)
174
- if selectEffect then res + FieldAccess (pot, symbol)(source)
182
+ if ignoreSelectEffect then res + FieldAccess (pot, symbol)(source)
175
183
else res
176
184
}
177
185
0 commit comments