diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-11-19 09:38:28 -0800 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-11-19 09:38:28 -0800 |
commit | 888d0b4868a62c8d8288a4a8b639d282355ac33f (patch) | |
tree | d937a0d4f4d5e7c28580dc393ca7e7047ad632e1 /src/compiler | |
parent | c81ef00dece5582f5f53b9b4320f7b755cc6bdae (diff) | |
parent | 32c57329a6cb7ff1fa479a1fce884b8166f3fc50 (diff) | |
download | scala-888d0b4868a62c8d8288a4a8b639d282355ac33f.tar.gz scala-888d0b4868a62c8d8288a4a8b639d282355ac33f.tar.bz2 scala-888d0b4868a62c8d8288a4a8b639d282355ac33f.zip |
Merge pull request #1638 from adriaanm/ticket-6624
SI-6624 better lookup of case field accessors for case class pattern with complicated type
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 5beba77155..938866deef 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -417,7 +417,17 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // (the prefix of the argument passed to the unapply must equal the prefix of the type of the binder) val treeMaker = TypeTestTreeMaker(patBinder, patBinder, extractor.paramType, extractor.paramType)(pos, extractorArgTypeTest = true) (List(treeMaker), treeMaker.nextBinder) - } else (Nil, patBinder) + } else { + // no type test needed, but the tree maker relies on `patBinderOrCasted` having type `extractor.paramType` (and not just some type compatible with it) + // SI-6624 shows this is necessary because apparently patBinder may have an unfortunate type (.decls don't have the case field accessors) + // TODO: get to the bottom of this -- I assume it happens when type checking infers a weird type for an unapply call + // by going back to the parameterType for the extractor call we get a saner type, so let's just do that for now + /* TODO: uncomment when `settings.developer` and `devWarning` become available + if (settings.developer.value && !(patBinder.info =:= extractor.paramType)) + devWarning(s"resetting info of $patBinder: ${patBinder.info} to ${extractor.paramType}") + */ + (Nil, patBinder setInfo extractor.paramType) + } withSubPats(typeTestTreeMaker :+ extractor.treeMaker(patBinderOrCasted, pos), extractor.subBindersAndPatterns: _*) } |