Skip to content

Commit bd42db9

Browse files
committed
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`.
1 parent 09dbf3f commit bd42db9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -952,11 +952,18 @@ trait Contexts { self: Analyzer =>
952952
private def importedAccessibleSymbol(imp: ImportInfo, name: Name, requireExplicit: Boolean): Symbol =
953953
imp.importedSymbol(name, requireExplicit) filter (s => isAccessible(s, imp.qual.tpe, superAccess = false))
954954

955+
private def requiresQualifier(s: Symbol) = (
956+
s.owner.isClass
957+
&& !s.owner.isPackageClass
958+
&& !s.isTypeParameterOrSkolem
959+
&& !s.isExistentiallyBound
960+
)
961+
955962
/** Must `sym` defined in package object of package `pkg`, if
956963
* it selected from a prefix with `pkg` as its type symbol?
957964
*/
958965
def isInPackageObject(sym: Symbol, pkg: Symbol): Boolean =
959-
pkg.isPackage && sym.owner != pkg && !sym.isExistentiallyBound
966+
pkg.isPackage && sym.owner != pkg && requiresQualifier(sym)
960967

961968
def isNameInScope(name: Name) = lookupSymbol(name, _ => true).isSuccess
962969

@@ -992,11 +999,6 @@ trait Contexts { self: Analyzer =>
992999
|| unit.exists && s.sourceFile != unit.source.file
9931000
)
9941001
)
995-
def requiresQualifier(s: Symbol) = (
996-
s.owner.isClass
997-
&& !s.owner.isPackageClass
998-
&& !s.isTypeParameterOrSkolem
999-
)
10001002
def lookupInPrefix(name: Name) = pre member name filter qualifies
10011003
def accessibleInPrefix(s: Symbol) = isAccessible(s, pre, superAccess = false)
10021004

0 commit comments

Comments
 (0)