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/ContextErrors.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/ContextErrors.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 89fc55bc2c..49f380086f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -592,6 +592,10 @@ trait ContextErrors { setError(tree) } + // typedPattern + def PatternMustBeValue(pat: Tree, pt: Type) = + issueNormalTypeError(pat, s"pattern must be a value: $pat"+ typePatternAdvice(pat.tpe.typeSymbol, pt.typeSymbol)) + // SelectFromTypeTree def TypeSelectionFromVolatileTypeError(tree: Tree, qual: Tree) = { val hiBound = qual.tpe.bounds.hi @@ -937,33 +941,10 @@ trait ContextErrors { def IncompatibleScrutineeTypeError(tree: Tree, pattp: Type, pt: Type) = issueNormalTypeError(tree, "scrutinee is incompatible with pattern type" + foundReqMsg(pattp, pt)) - def PatternTypeIncompatibleWithPtError2(pat: Tree, pt1: Type, pt: Type) = { - def errMsg = { - val sym = pat.tpe.typeSymbol - val clazz = sym.companionClass - val addendum = ( - if (sym.isModuleClass && clazz.isCaseClass && (clazz isSubClass pt1.typeSymbol)) { - // TODO: move these somewhere reusable. - val typeString = clazz.typeParams match { - case Nil => "" + clazz.name - case xs => xs map (_ => "_") mkString (clazz.name + "[", ",", "]") - } - val caseString = ( - clazz.caseFieldAccessors - map (_ => "_") // could use the actual param names here - mkString (clazz.name + "(", ",", ")") - ) - ( - "\nNote: if you intended to match against the class, try `case _: " + - typeString + "` or `case " + caseString + "`" - ) - } - else "" - ) - "pattern type is incompatible with expected type"+foundReqMsg(pat.tpe, pt) + addendum - } - issueNormalTypeError(pat, errMsg) - } + def PatternTypeIncompatibleWithPtError2(pat: Tree, pt1: Type, pt: Type) = + issueNormalTypeError(pat, + "pattern type is incompatible with expected type"+ foundReqMsg(pat.tpe, pt) + + typePatternAdvice(pat.tpe.typeSymbol, pt1.typeSymbol)) def PolyAlternativeError(tree: Tree, argtypes: List[Type], sym: Symbol, err: PolyAlternativeErrorKind.ErrorType) = { import PolyAlternativeErrorKind._ |