diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-05-25 22:32:56 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-05-25 23:13:10 +1000 |
commit | bd42db9e344e317a8cd83097d5278d915cfa0f0f (patch) | |
tree | e2c7ad8517508e2f99b0f5fdab915a248d5a34a1 /src | |
parent | 09dbf3f148b0dc04e10dd50ed2aa626c26afaeec (diff) | |
download | scala-bd42db9e344e317a8cd83097d5278d915cfa0f0f.tar.gz scala-bd42db9e344e317a8cd83097d5278d915cfa0f0f.tar.bz2 scala-bd42db9e344e317a8cd83097d5278d915cfa0f0f.zip |
SI-9326 Binding to existentials can discard the prefix
Refines the previous commit by changing `Context#lookup` to
consider existential quantifiers, in the same manner as type
parameters, as exempt from consideration of the lookup prefix.
Furthermore, this logic is shared with `isInPackageObject`.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 25c800e4d0..7c931600e5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -952,11 +952,18 @@ trait Contexts { self: Analyzer => private def importedAccessibleSymbol(imp: ImportInfo, name: Name, requireExplicit: Boolean): Symbol = imp.importedSymbol(name, requireExplicit) filter (s => isAccessible(s, imp.qual.tpe, superAccess = false)) + private def requiresQualifier(s: Symbol) = ( + s.owner.isClass + && !s.owner.isPackageClass + && !s.isTypeParameterOrSkolem + && !s.isExistentiallyBound + ) + /** Must `sym` defined in package object of package `pkg`, if * it selected from a prefix with `pkg` as its type symbol? */ def isInPackageObject(sym: Symbol, pkg: Symbol): Boolean = - pkg.isPackage && sym.owner != pkg && !sym.isExistentiallyBound + pkg.isPackage && sym.owner != pkg && requiresQualifier(sym) def isNameInScope(name: Name) = lookupSymbol(name, _ => true).isSuccess @@ -992,11 +999,6 @@ trait Contexts { self: Analyzer => || unit.exists && s.sourceFile != unit.source.file ) ) - def requiresQualifier(s: Symbol) = ( - s.owner.isClass - && !s.owner.isPackageClass - && !s.isTypeParameterOrSkolem - ) def lookupInPrefix(name: Name) = pre member name filter qualifies def accessibleInPrefix(s: Symbol) = isAccessible(s, pre, superAccess = false) |