summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-29 21:42:25 +0000
committerPaul Phillips <paulp@improving.org>2011-07-29 21:42:25 +0000
commit9bdc1a0b6deb5bf8a056af0253b25fcf5d92c7f7 (patch)
tree9625ceb6358baf68b84eae5e1dc6fa74d267e425 /src/compiler/scala/tools/nsc/typechecker
parent902c61f397069b9918f1854b8bf95a50b52c08fc (diff)
downloadscala-9bdc1a0b6deb5bf8a056af0253b25fcf5d92c7f7.tar.gz
scala-9bdc1a0b6deb5bf8a056af0253b25fcf5d92c7f7.tar.bz2
scala-9bdc1a0b6deb5bf8a056af0253b25fcf5d92c7f7.zip
Following up on things that -Xlint told me, som...
Following up on things that -Xlint told me, sometimes because Mr. Linty was being sensible and other times just to shut him up so we can hear better in the future. - made xml.Equality public because it occurs in public method signatures - made some actor classes with inaccessible-unoverridable methods final - eliminated a bunch of "dead code follows" warnings by deleting the dead code which really did follow - improved the reliability of warnings about inaccessible types For the changes in actors, review by phaller.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Adaptations.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala21
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
4 files changed, 18 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala b/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala
index 3dee4650de..99d5363d5e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala
@@ -59,6 +59,7 @@ trait Adaptations {
// an opt-in compiler option is given.
oneArgObject && !(
isStringAddition(t.symbol)
+ || isArrowAssoc(t.symbol)
|| t.symbol.name == nme.equals_
|| t.symbol.name == nme.EQ
|| t.symbol.name == nme.NE
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 765881ac81..097bbf5915 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -219,7 +219,7 @@ trait Implicits {
object Function1 {
val Sym = FunctionClass(1)
def unapply(tp: Type) = tp match {
- case TypeRef(_, Sym, arg1 :: arg2 :: _) => Some(arg1, arg2)
+ case TypeRef(_, Sym, arg1 :: arg2 :: _) => Some((arg1, arg2))
case _ => None
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 8e1ee97387..37b5870ac5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1221,22 +1221,27 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
otherSym.decodedName, cannot, memberSym.decodedName)
)
}
+
/** Warn about situations where a method signature will include a type which
* has more restrictive access than the method itself.
*/
private def checkAccessibilityOfReferencedTypes(tree: Tree) {
val member = tree.symbol
- // types of the value parameters
- member.paramss.flatten foreach { p =>
- val normalized = p.tpe.normalize
- if ((normalized ne p.tpe) && lessAccessibleSymsInType(normalized, member).isEmpty) ()
- else lessAccessibleSymsInType(p.tpe, member) foreach (sym => warnLessAccessible(sym, member))
+ def checkAccessibilityOfType(tpe: Type) {
+ val inaccessible = lessAccessibleSymsInType(tpe, member)
+ // if the unnormalized type is accessible, that's good enough
+ if (inaccessible.isEmpty) ()
+ // or if the normalized type is, that's good too
+ else if ((tpe ne tpe.normalize) && lessAccessibleSymsInType(tpe.normalize, member).isEmpty) ()
+ // otherwise warn about the inaccessible syms in the unnormalized type
+ else inaccessible foreach (sym => warnLessAccessible(sym, member))
}
+
+ // types of the value parameters
+ member.paramss.flatten foreach (p => checkAccessibilityOfType(p.tpe))
// upper bounds of type parameters
- member.typeParams.map(_.info.bounds.hi.widen) foreach { tp =>
- lessAccessibleSymsInType(tp, member) foreach (sym => warnLessAccessible(sym, member))
- }
+ member.typeParams.map(_.info.bounds.hi.widen) foreach checkAccessibilityOfType
}
/** Check that a deprecated val or def does not override a
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 4125ab0285..23482eb609 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2118,6 +2118,8 @@ trait Typers extends Modes with Adaptations {
} else {
val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this
else newTyper(context.make(stat, exprOwner))
+ // XXX this creates a spurious dead code warning if an exception is thrown
+ // in a constructor, even if it is the only thing in the constructor.
val result = checkDead(localTyper.typed(stat, EXPRmode | BYVALmode, WildcardType))
if (treeInfo.isSelfOrSuperConstrCall(result)) {
context.inConstructorSuffix = true
@@ -2202,7 +2204,7 @@ trait Typers extends Modes with Adaptations {
}) ::: newStats.toList
}
}
- val result = stats mapConserve (typedStat)
+ val result = stats mapConserve typedStat
if (phase.erasedTypes) result
else checkNoDoubleDefsAndAddSynthetics(result)
}