Skip to content

Commit 3f16257

Browse files
committed
Address review
1 parent 00d05b4 commit 3f16257

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

compiler/src/dotty/tools/dotc/transform/init/Checking.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ object Checking {
347347

348348
case _ =>
349349
val Summary(pots, effs) = expand(pot1)
350-
val Summary(pots2, effs2) = pots.select(sym, pot.source, selectEffect = false)
350+
val Summary(pots2, effs2) = pots.select(sym, pot.source, ignoreSelectEffect = false)
351351
Summary(pots2, effs ++ effs2)
352352
}
353353

@@ -376,7 +376,7 @@ object Checking {
376376

377377
case _ =>
378378
val Summary(pots, effs) = expand(pot1)
379-
val Summary(pots2, effs2) = pots.select(sym, pot.source, selectEffect = false)
379+
val Summary(pots2, effs2) = pots.select(sym, pot.source, ignoreSelectEffect = false)
380380
Summary(pots2, effs ++ effs2)
381381
}
382382

compiler/src/dotty/tools/dotc/transform/init/Potentials.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)