diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-11-19 21:19:25 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-11-26 22:29:26 +0100 |
commit | 0271a4a3944153bb4fcc81e3b250bc084b692db3 (patch) | |
tree | ce1748ebff2d90db1fdccd60b8b6bab58f1b55e0 /src/compiler | |
parent | 7cd50ba39c332c39990bc3a7103e1f86b040032e (diff) | |
download | scala-0271a4a3944153bb4fcc81e3b250bc084b692db3.tar.gz scala-0271a4a3944153bb4fcc81e3b250bc084b692db3.tar.bz2 scala-0271a4a3944153bb4fcc81e3b250bc084b692db3.zip |
SI-7984 Issue unchecked warning for type aliases
- Dealias pattern types before launching the CheckabilityChecker
- Sharpen the error messages to explain that the dealiased type
is the expansion of the alias.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Checkable.scala | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Checkable.scala b/src/compiler/scala/tools/nsc/typechecker/Checkable.scala index 0eae17612d..94f8f509fc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Checkable.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Checkable.scala @@ -259,10 +259,12 @@ trait Checkable { if (uncheckedOk(P0)) return def where = if (inPattern) "pattern " else "" - // singleton types not considered here - val P = P0.widen + // singleton types not considered here, dealias the pattern for SI-XXXX + val P = P0.dealiasWiden val X = X0.widen + def PString = if (P eq P0) P.toString else s"$P (the underlying of $P0)" + P match { // Prohibit top-level type tests for these, but they are ok nested (e.g. case Foldable[Nothing] => ... ) case TypeRef(_, NothingClass | NullClass | AnyValClass, _) => @@ -282,12 +284,12 @@ trait Checkable { if (checker.neverMatches) { val addendum = if (checker.neverSubClass) "" else " (but still might match its erasure)" - getContext.unit.warning(tree.pos, s"fruitless type test: a value of type $X cannot also be a $P$addendum") + getContext.unit.warning(tree.pos, s"fruitless type test: a value of type $X cannot also be a $PString$addendum") } else if (checker.isUncheckable) { val msg = ( - if (checker.uncheckableType =:= P) s"abstract type $where$P" - else s"${checker.uncheckableMessage} in type $where$P" + if (checker.uncheckableType =:= P) s"abstract type $where$PString" + else s"${checker.uncheckableMessage} in type $where$PString" ) getContext.unit.warning(tree.pos, s"$msg is unchecked since it is eliminated by erasure") } |