@@ -155,23 +155,31 @@ object Potentials {
155155
156156 extension (pot : Potential ) def toPots : Potentials = Potentials .empty + pot
157157
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 =
159167 ps.foldLeft(Summary .empty) { case (summary, pot) =>
160168 // max potential length
161169 // TODO: it can be specified on a project basis via compiler options
162170 if (pot.size > 2 )
163171 summary + Promote (pot)(pot.source)
164172 else if (symbol.isConstructor)
165173 val res = summary + pot
166- if selectEffect then res + MethodCall (pot, symbol)(source)
174+ if ignoreSelectEffect then res + MethodCall (pot, symbol)(source)
167175 else res
168176 else if (symbol.isOneOf(Flags .Method | Flags .Lazy ))
169177 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)
171179 else res
172180 else
173181 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)
175183 else res
176184 }
177185
0 commit comments