diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-23 19:04:33 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-11-24 09:44:24 +0100 |
commit | 473230c638820b9c1d9cf40c218a5e9fc8caaa9f (patch) | |
tree | 0105f321719027db5baeaaf8bfad91f6cc4b9ee1 /compiler/src/dotty/tools | |
parent | a72ba85afe9950f573cbced60aa37154ae0040e2 (diff) | |
download | dotty-473230c638820b9c1d9cf40c218a5e9fc8caaa9f.tar.gz dotty-473230c638820b9c1d9cf40c218a5e9fc8caaa9f.tar.bz2 dotty-473230c638820b9c1d9cf40c218a5e9fc8caaa9f.zip |
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.
Diffstat (limited to 'compiler/src/dotty/tools')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Symbols.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Typer.scala | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index c0427e320..cfd85c49c 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -428,7 +428,7 @@ object Symbols { final def entered(implicit ctx: Context): this.type = { assert(this.owner.isClass, s"symbol ($this) entered the scope of non-class owner ${this.owner}") // !!! DEBUG this.owner.asClass.enter(this) - if (this.is(Module, butNot = Package)) this.owner.asClass.enter(this.moduleClass) + if (this is Module) this.owner.asClass.enter(this.moduleClass) this } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 64936e106..9f5a942d6 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -120,15 +120,20 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } else false - /** A symbol qualifies if it really exists. In addition, - * if we are in a constructor of a pattern, we ignore all definitions + /** A symbol qualifies if it really exists and is not a package class. + * In addition, if we are in a constructor of a pattern, we ignore all definitions * which are methods and not accessors (note: if we don't do that * case x :: xs in class List would return the :: method). + * + * Package classes are part of their parent's scope, because otherwise + * we could not reload them via `_.member`. On the other hand, accessing a + * package as a type from source is always an error. */ def qualifies(denot: Denotation): Boolean = - reallyExists(denot) && !( - pt.isInstanceOf[UnapplySelectionProto] && - (denot.symbol is (Method, butNot = Accessor))) + reallyExists(denot) && + !(pt.isInstanceOf[UnapplySelectionProto] && + (denot.symbol is (Method, butNot = Accessor))) && + !(denot.symbol is PackageClass) /** Find the denotation of enclosing `name` in given context `ctx`. * @param previous A denotation that was found in a more deeply nested scope, |