Skip to content

Commit 3bf80c9

Browse files
Compute isDependent by looking at owners instead
...of outers. Hopefully this worksarounds all the issues related to
1 parent 686ff5d commit 3bf80c9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,24 @@ object Contexts {
162162
_typeComparer
163163
}
164164

165-
/** Is this context transparent? */
165+
/** Is this context dependent? */
166166
private[this] var _dependentInit: Boolean = true // NOTE: This initial value only applies to InitialContext
167167
private[this] var _dependent: Boolean = false
168168
final def isDependent: Boolean = {
169+
def isDepOwner(owner: Symbol): Boolean =
170+
if ((owner eq NoSymbol) || owner.isClass) false
171+
else if (owner.flagsUNSAFE.is(Flags.Dependent)) true
172+
else isDepOwner(owner.owner)
173+
169174
/** NOTE: The initialization of `_dependent` is rather tricky: We do need to make sure that any
170175
* enclosing context's `_dependent` has been computed, since the property is inherited. In case the
171-
* outer's `transparent` has been accessed before, we inherit the value by way of clone() in fresh(),
176+
* outer's `dependent` has been accessed before, we inherit the value by way of clone() in fresh(),
172177
* (and as a result `_dependentInit` will be true as well).
173178
* Otherwise we force the enclosing context's `_dependent` here, and, if the outer turns out not to be
174-
* transparent, we finally also compute `_dependent` based on this context.
179+
* dependent, we finally also compute `_dependent` based on this context.
175180
*/
176181
if (!_dependentInit) {
177-
val S = this.base.settings
178-
_dependent = if (owner eq NoSymbol) false else
179-
this.mode.is(Mode.InTypeOf) ||
180-
!this.owner.isClass && (
181-
outer.isDependent ||
182-
this.owner.flagsUNSAFE.is(Flags.Dependent)
183-
)
182+
_dependent = this.mode.is(Mode.InTypeOf) || isDepOwner(this.owner)
184183
_dependentInit = true
185184
}
186185
_dependent

0 commit comments

Comments
 (0)