Skip to content

Commit 473230c

Browse files
oderskyfelixmulder
authored andcommitted
Revert fix to #1701.
Fengyun's original solution was the right one. We cannot NOT enter a package class into its parent scope, because reloading the denotation with .member will fail. So we need to enter it and compensate by adding a clause to `qualifies` in `typedIdent`. Weirdly, this was noted only when running tasty_bootstrap from a custom classpath in the new build setup. So it was pretty tricky to diagnose.
1 parent a72ba85 commit 473230c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ object Symbols {
428428
final def entered(implicit ctx: Context): this.type = {
429429
assert(this.owner.isClass, s"symbol ($this) entered the scope of non-class owner ${this.owner}") // !!! DEBUG
430430
this.owner.asClass.enter(this)
431-
if (this.is(Module, butNot = Package)) this.owner.asClass.enter(this.moduleClass)
431+
if (this is Module) this.owner.asClass.enter(this.moduleClass)
432432
this
433433
}
434434

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,20 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
120120
}
121121
else false
122122

123-
/** A symbol qualifies if it really exists. In addition,
124-
* if we are in a constructor of a pattern, we ignore all definitions
123+
/** A symbol qualifies if it really exists and is not a package class.
124+
* In addition, if we are in a constructor of a pattern, we ignore all definitions
125125
* which are methods and not accessors (note: if we don't do that
126126
* case x :: xs in class List would return the :: method).
127+
*
128+
* Package classes are part of their parent's scope, because otherwise
129+
* we could not reload them via `_.member`. On the other hand, accessing a
130+
* package as a type from source is always an error.
127131
*/
128132
def qualifies(denot: Denotation): Boolean =
129-
reallyExists(denot) && !(
130-
pt.isInstanceOf[UnapplySelectionProto] &&
131-
(denot.symbol is (Method, butNot = Accessor)))
133+
reallyExists(denot) &&
134+
!(pt.isInstanceOf[UnapplySelectionProto] &&
135+
(denot.symbol is (Method, butNot = Accessor))) &&
136+
!(denot.symbol is PackageClass)
132137

133138
/** Find the denotation of enclosing `name` in given context `ctx`.
134139
* @param previous A denotation that was found in a more deeply nested scope,

0 commit comments

Comments
 (0)