diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-05-02 13:21:06 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-05-02 16:18:35 +0200 |
commit | 49f50727944a478bc5d10ad0658437286f47e422 (patch) | |
tree | c4e7a931f24cccf3c371fca440ad94dd19efd371 /src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | |
parent | 5819b78c25c9cba25fc84018d3905fe265bb4e18 (diff) | |
parent | 98972c95ab1e7c0ea2af9c9a958c0de60eb26b3d (diff) | |
download | scala-49f50727944a478bc5d10ad0658437286f47e422.tar.gz scala-49f50727944a478bc5d10ad0658437286f47e422.tar.bz2 scala-49f50727944a478bc5d10ad0658437286f47e422.zip |
Merge 2.10.x into master
Conflicts:
bincompat-forward.whitelist.conf
src/compiler/scala/tools/nsc/matching/Patterns.scala
src/compiler/scala/tools/nsc/transform/patmat/Logic.scala
src/compiler/scala/tools/nsc/typechecker/Infer.scala
src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
test/files/neg/t5663-badwarneq.check
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 5f45fead91..5146cf6fa7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -271,6 +271,24 @@ trait TypeDiagnostics { ) } + def typePatternAdvice(sym: Symbol, ptSym: Symbol) = { + val clazz = if (sym.isModuleClass) sym.companionClass else sym + val caseString = + if (clazz.isCaseClass && (clazz isSubClass ptSym)) + ( clazz.caseFieldAccessors + map (_ => "_") // could use the actual param names here + mkString (s"`case ${clazz.name}(", ",", ")`") + ) + else + "`case _: " + (clazz.typeParams match { + case Nil => "" + clazz.name + case xs => xs map (_ => "_") mkString (clazz.name + "[", ",", "]") + })+ "`" + + "\nNote: if you intended to match against the class, try "+ caseString + + } + case class TypeDiag(tp: Type, sym: Symbol) extends Ordered[TypeDiag] { // save the name because it will be mutated until it has been // distinguished from the other types in the same error message |