Skip to content

Fix Tasty reflect with varargs in unapply #4877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

case _ => None
}
private def effectivePatterns(patterns: List[Pattern]): List[Pattern] = patterns match {
case patterns0 :+ Trees.SeqLiteral(elems, _) => patterns0 ::: elems
case _ => patterns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that patterns only contain SeqLiteral?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the last one can one can have the SeqLiteral as only the last argument can be a varargs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's nice to have a link to test case here, as it's really difficult to figure out the test case
  2. The code fails to handle the following case:
case class D(b: B[_]*)

class Test {
  def f2(d: D) = d match {
    case D(a, b1, b2) => ()
  }
}

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

case _ => None
}
private def effectivePatterns(patterns: List[Pattern]): List[Pattern] = patterns match {
case patterns0 :+ Trees.SeqLiteral(elems, _) => patterns0 ::: elems
case _ => patterns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's nice to have a link to test case here, as it's really difficult to figure out the test case
  2. The code fails to handle the following case:
case class D(b: B[_]*)

class Test {
  def f2(d: D) = d match {
    case D(a, b1, b2) => ()
  }
}

@nicolasstucki nicolasstucki force-pushed the fix-tasty-reflect-literal-seq-unapply branch from c0edcb6 to 457b554 Compare July 31, 2018 13:48
@nicolasstucki nicolasstucki merged commit 6b8b260 into scala:master Jul 31, 2018
@allanrenucci allanrenucci deleted the fix-tasty-reflect-literal-seq-unapply branch July 31, 2018 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants