Skip to content

Commit 4cb493a

Browse files
committed
Allow for aut-updating of package members
Previously, an overwritten package member always got the denotation of the new package, so package members always auto-updated, and we could not even detect that they were no longer valid. This is a problem because it means that TermRefs and TypeRefs pointing to overwritten members will not be updated. We now do something less sweeping. A call to `current` will invoke `bringForward` which will do the update if the `autoUpdatePackageMembers` config flag is set. After the call to `current` the old symbol will be considered valid, which is a potential problems because we then have two valid symbols pointing to the same denotations. So it would be best if we could set `autoUpdatePackageMembers = false`.
1 parent 58615af commit 4cb493a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/config/Config.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ object Config {
144144
*/
145145
final val simplifyApplications = true
146146

147+
/** If this flag is on, automatically being forward no-longer valid package members.
148+
* If it is off, raise a StaleSymbol error instead.
149+
*/
150+
final val autoUpdatePackageMembers = true
151+
147152
/** If set, prints a trace of all symbol completions */
148153
final val showCompletions = false
149154

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ object Denotations {
779779
this match {
780780
case symd: SymDenotation =>
781781
if (ctx.stillValid(symd)) return updateValidity()
782-
if (symd.owner.is(Package)) {
782+
if (Config.autoUpdatePackageMembers && symd.owner.is(Package)) {
783783
val newd = symd.owner.info.decls.lookup(symd.name)
784784
if (newd.exists) return newd
785785
}

0 commit comments

Comments
 (0)