summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-11-25 14:53:50 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-11-25 14:54:05 +1000
commite07d62cdefd5b01734692fc549521e562984ccb0 (patch)
treeca9c8204ee7c13278a900a9c6d08293167d4bc23 /src
parent4e4709a3b0dd869b98c1a8d854f4a54145ade2ff (diff)
downloadscala-e07d62cdefd5b01734692fc549521e562984ccb0.tar.gz
scala-e07d62cdefd5b01734692fc549521e562984ccb0.tar.bz2
scala-e07d62cdefd5b01734692fc549521e562984ccb0.zip
SI-9567 Fix pattern match on 23+ param, method local case class
Typechecking constructor patterns of method local case classes was only working because of the existence of the unapply method in the companion, which is used if navigation to the case class companion object fails. We now support defintion of, and pattern matching on, case classes with more than 22 parameters. These have no `unapply` method in the companion, as we don't have a large enough tuple type to return. So for such case classes, the fallback that we inadvertently relied on would no longer save us, and we'd end up with a compile error advising that the identifier in the constructor pattern was neither a case class nor an extractor. This is due to the propensity of `Symbol#companionXxx` to return `NoSymbol` when in the midst of typechecking. That method should only be relied upon after typechecking. During typechecking, `Namers#companionSymbolOf` should be used instead, which looks in the scopes of enclosing contexts for symbol companionship. That's what I've done in this commit.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
index a702b3cdf5..f90e61ff92 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
@@ -79,7 +79,7 @@ trait PatternTypers {
// do not update the symbol if the tree's symbol's type does not define an unapply member
// (e.g. since it's some method that returns an object with an unapply member)
val fun = inPlaceAdHocOverloadingResolution(fun0)(hasUnapplyMember)
- val caseClass = fun.tpe.typeSymbol.linkedClassOfClass
+ val caseClass = companionSymbolOf(fun.tpe.typeSymbol.sourceModule, context)
val member = unapplyMember(fun.tpe)
def resultType = (fun.tpe memberType member).finalResultType
def isEmptyType = resultOfMatchingMethod(resultType, nme.isEmpty)()