summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala42
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
5 files changed, 37 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 2a7f11325c..d735044e07 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -39,7 +39,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
"memberSym " + memberSym + " templateSym " + templateSym + " encls = " +
closestPackage(memberSym) + ", " + closestPackage(templateSym)
)
- memberSym.inDefaultNamespace || (closestPackage(memberSym) == closestPackage(templateSym))
+ memberSym.isOmittablePrefix || (closestPackage(memberSym) == closestPackage(templateSym))
}
private lazy val noSubclassCache = Set(AnyClass, AnyRefClass, ObjectClass, ScalaObjectClass)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 169295e5c9..660999eb64 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -335,8 +335,8 @@ trait Implicits {
pre1: String, pre2: String, trailer: String) =
if (!info1.tpe.isErroneous && !info2.tpe.isErroneous) {
val coreMsg =
- pre1+" "+info1.sym+info1.sym.locationString+" of type "+info1.tpe+"\n "+
- pre2+" "+info2.sym+info2.sym.locationString+" of type "+info2.tpe+"\n "+
+ pre1+" "+info1.sym.fullLocationString+" of type "+info1.tpe+"\n "+
+ pre2+" "+info2.sym.fullLocationString+" of type "+info2.tpe+"\n "+
trailer
error(tree.pos,
if (isView) {
@@ -408,7 +408,7 @@ trait Implicits {
if (!(pt.isErroneous))
context.unit.error(
tree.pos, "diverging implicit expansion for type "+pt+"\nstarting with "+
- info.sym+info.sym.locationString)
+ info.sym.fullLocationString)
SearchFailure
} else {
throw DivergentImplicit
@@ -545,7 +545,7 @@ trait Implicits {
SearchFailure
else if (!hasMatchingSymbol(itree1))
fail("candidate implicit %s is shadowed by other implicit %s".format(
- info.sym + info.sym.locationString, itree1.symbol + itree1.symbol.locationString))
+ info.sym.fullLocationString, itree1.symbol.fullLocationString))
else {
val tvars = undetParams map freshVar
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 360acbd469..31aaaa36b8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -403,7 +403,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
val isCandidate = (
sym.isProtected
&& sym.isJavaDefined
- && !sym.definedInPackage
+ && !sym.isDefinedInPackage
&& !accessibleThroughSubclassing
&& (sym.owner.enclosingPackageClass != currentOwner.enclosingPackageClass)
&& (sym.owner.enclosingPackageClass == packageAccessBoundry(sym))
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 6e0e78e8e2..6c735a2d44 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -82,6 +82,17 @@ trait TypeDiagnostics {
def posPrecedes(p1: Position, p2: Position) = p1.isDefined && p2.isDefined && p1.line < p2.line
def linePrecedes(t1: Tree, t2: Tree) = posPrecedes(t1.pos, t2.pos)
+ private object DealiasedType extends TypeMap {
+ def apply(tp: Type): Type = tp match {
+ // Avoid "explaining" that String is really java.lang.String,
+ // while still dealiasing types from non-default namespaces.
+ case TypeRef(pre, sym, args) if sym.isAliasType && !sym.isInDefaultNamespace =>
+ mapOver(tp.dealias)
+ case _ =>
+ mapOver(tp)
+ }
+ }
+
def notAMemberMessage(pos: Position, qual: Tree, name: Name) = {
val owner = qual.tpe.typeSymbol
val target = qual.tpe.widen
@@ -212,12 +223,17 @@ trait TypeDiagnostics {
else if (sym.variance == -1) "contravariant"
else "invariant"
- // I think this should definitely be on by default, but I need to
- // play with it a bit longer. For now it's behind -Xlint.
- def explainAlias(tp: Type) = (
- if (!settings.lint.value || (tp eq tp.normalize)) ""
- else " (which expands to)\n " + tp.normalize
- )
+ def explainAlias(tp: Type) = {
+ // Don't automatically normalize standard aliases; they still will be
+ // expanded if necessary to disambiguate simple identifiers.
+ if ((tp eq tp.normalize) || tp.typeSymbolDirect.isInDefaultNamespace) ""
+ else {
+ // A sanity check against expansion being identical to original.
+ val s = "" + DealiasedType(tp)
+ if (s == "" + tp) ""
+ else "\n (which expands to) " + s
+ }
+ }
/** Look through the base types of the found type for any which
* might have been valid subtypes if given conformant type arguments.
@@ -292,7 +308,6 @@ trait TypeDiagnostics {
}
"" // no elaborable variance situation found
}
-
def foundReqMsg(found: Type, req: Type): String = (
withDisambiguation(Nil, found, req)(
";\n found : " + found.toLongString + existentialContext(found) + explainAlias(found) +
@@ -309,8 +324,11 @@ trait TypeDiagnostics {
def modifyName(f: String => String) =
sym.name = newTypeName(f(sym.name.toString))
- def scalaQualify() = {
- val intersect = Set(trueOwner, aliasOwner) intersect Set(ScalaPackageClass, PredefModuleClass)
+ /** Prepend java.lang, scala., or Predef. if this type originated
+ * in one of those.
+ */
+ def qualifyDefaultNamespaces() = {
+ val intersect = Set(trueOwner, aliasOwner) intersect UnqualifiedOwners
if (intersect.nonEmpty) preQualify()
}
@@ -320,8 +338,8 @@ trait TypeDiagnostics {
def typeQualify() = if (sym.isTypeParameterOrSkolem) postQualify()
def nameQualify() = if (trueOwner.isPackageClass) preQualify() else postQualify()
- def trueOwner = tp.typeSymbol.owner.skipPackageObject
- def aliasOwner = tp.typeSymbolDirect.owner.skipPackageObject
+ def trueOwner = tp.typeSymbol.effectiveOwner
+ def aliasOwner = tp.typeSymbolDirect.effectiveOwner
def sym_==(other: TypeDiag) = tp.typeSymbol == other.tp.typeSymbol
def owner_==(other: TypeDiag) = trueOwner == other.trueOwner
@@ -385,7 +403,7 @@ trait TypeDiagnostics {
// scala package or predef, qualify with scala so it is not confusing why
// e.g. java.util.Iterator and Iterator are different types.
if (td1 name_== td2)
- tds foreach (_.scalaQualify())
+ tds foreach (_.qualifyDefaultNamespaces())
// If they still print identically:
// a) If they are type parameters with different owners, append (in <owner>)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 5bd936bfb7..deff4c10a2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3848,7 +3848,7 @@ trait Typers extends Modes with Adaptations {
if (defSym.exists && impSym.exists) {
// imported symbols take precedence over package-owned symbols in different
// compilation units. Defined symbols take precedence over erroneous imports.
- if (defSym.definedInPackage &&
+ if (defSym.isDefinedInPackage &&
(!currentRun.compiles(defSym) ||
context.unit.exists && defSym.sourceFile != context.unit.source.file))
defSym = NoSymbol