SI-6624 better lookup of case field accessors for case class pattern with complicated type #1638

Merged
merged 1 commit into from Nov 19, 2012

Conversation

Projects
None yet
5 participants
@adriaanm
Member

adriaanm commented Nov 16, 2012

(I need to run, but wanted to let the bot build this already -- will assign reviewer etc ASAP)

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins Nov 16, 2012

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins Nov 16, 2012

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins Nov 16, 2012

Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/1675/

@scala-jenkins

This comment has been minimized.

Show comment
Hide comment
@scala-jenkins

scala-jenkins Nov 16, 2012

jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/1675/

@adriaanm

This comment has been minimized.

Show comment
Hide comment
@adriaanm

adriaanm Nov 16, 2012

Member

review by @retronym

Member

adriaanm commented Nov 16, 2012

review by @retronym

@retronym

This comment has been minimized.

Show comment
Hide comment
@retronym

retronym Nov 16, 2012

Member

lgtm

Member

retronym commented Nov 16, 2012

lgtm

@paulp

View changes

src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
+ // 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
+ (Nil, patBinder setInfo extractor.paramType)
+ }

This comment has been minimized.

@paulp

paulp Nov 16, 2012

Contributor

This seems like the kind of hinges-on-a-subtlety place where we would benefit from some logging. If you want to get to the bottom of this faster,

if (settings.developer.value) { // depends on another pull request
  if (!(patBinder.info =:= extractor.paramType))
    devWarning("say something useful...")
}
@paulp

paulp Nov 16, 2012

Contributor

This seems like the kind of hinges-on-a-subtlety place where we would benefit from some logging. If you want to get to the bottom of this faster,

if (settings.developer.value) { // depends on another pull request
  if (!(patBinder.info =:= extractor.paramType))
    devWarning("say something useful...")
}
SI-6624 set info of case pattern binder to help find case field acces…
…sors

sometimes the type checker infers a weird type for a sub-pattern of a case class/extractor pattern
this confuses the pattern matcher and it can't find the case field accessors for the sub-pattern

use the expected argument type of the extractor corresponding to the case class that we're matching
as the info for the sub-pattern binder -- this type more readily admits querying its caseFieldAccessors
@adriaanm

This comment has been minimized.

Show comment
Hide comment
@adriaanm

adriaanm Nov 17, 2012

Member

(the commit was only updated to improve docs/commit message)

Member

adriaanm commented Nov 17, 2012

(the commit was only updated to improve docs/commit message)

jsuereth added a commit that referenced this pull request Nov 19, 2012

Merge pull request #1638 from adriaanm/ticket-6624
SI-6624 better lookup of case field accessors for case class pattern with complicated type

@jsuereth jsuereth merged commit 888d0b4 into scala:2.10.0-wip Nov 19, 2012

@scabug scabug referenced this pull request in scala/bug Apr 7, 2017

Closed

virpatmat crasher: _1 is not a member of #6624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment