diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-09-19 14:33:45 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-09-19 18:41:52 +1000 |
commit | 581e2c2455524123ed259adcfc66817f7fc04726 (patch) | |
tree | 825e083e0fe7f9ed912e199dc783c350ef96377f /src/compiler/scala/tools/nsc/typechecker/Contexts.scala | |
parent | 46c81c6be94152f8ecf3b9cfc27ca1bb393b46f1 (diff) | |
download | scala-581e2c2455524123ed259adcfc66817f7fc04726.tar.gz scala-581e2c2455524123ed259adcfc66817f7fc04726.tar.bz2 scala-581e2c2455524123ed259adcfc66817f7fc04726.zip |
SI-9479 Fix regression w. inherited overloads in package object
One shouldn't base any decisions of the owner of an overloaded
symbol. Instead, the owner of each of the alternatives should
be considered.
This gotcha is super easy to forget, as I did with my change to
simplify the way we detect whether we need to add the `.package`
prefix to a tree.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 2ccf375c45..c28cd8d69c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -957,7 +957,7 @@ trait Contexts { self: Analyzer => private def importedAccessibleSymbol(imp: ImportInfo, name: Name, requireExplicit: Boolean, record: Boolean): Symbol = imp.importedSymbol(name, requireExplicit, record) filter (s => isAccessible(s, imp.qual.tpe, superAccess = false)) - private def requiresQualifier(s: Symbol) = ( + private def requiresQualifier(s: Symbol): Boolean = ( s.owner.isClass && !s.owner.isPackageClass && !s.isTypeParameterOrSkolem @@ -967,8 +967,10 @@ trait Contexts { self: Analyzer => /** 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 && requiresQualifier(sym) + def isInPackageObject(sym: Symbol, pkg: Symbol): Boolean = { + if (sym.isOverloaded) sym.alternatives.exists(alt => isInPackageObject(alt, pkg)) + else pkg.isPackage && sym.owner != pkg && requiresQualifier(sym) + } def isNameInScope(name: Name) = lookupSymbol(name, _ => true).isSuccess |