Skip to content
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

Fix #6849: support irrefutable sequence match #6850

Merged
merged 12 commits into from Jan 16, 2020

Conversation

@liufengyun
Copy link
Contributor

liufengyun commented Jul 15, 2019

  • Fix #6490: Add spec for irrefutable extractors
  • Fix #6849: support irrefutable sequence match
@liufengyun liufengyun changed the title Fix #6849: support urrefutable sequence match Fix #6849: support irrefutable sequence match Jul 15, 2019
@liufengyun liufengyun force-pushed the dotty-staging:fix-6490 branch from ea8704c to 0873373 Jul 15, 2019
@liufengyun liufengyun requested a review from smarter Jul 19, 2019
@odersky

This comment has been minimized.

Copy link
Contributor

odersky commented Dec 12, 2019

@liufengyun Can we revive this before the release? It seems this is important functionality.

@odersky odersky closed this Dec 12, 2019
@odersky odersky reopened this Dec 12, 2019
@liufengyun liufengyun force-pushed the dotty-staging:fix-6490 branch 2 times, most recently from b3b0b55 to f0b38e1 Dec 13, 2019
@liufengyun liufengyun requested a review from nicolasstucki Dec 13, 2019
def unapplySeq(x: Any): ThreeStringExtract = new ThreeStringExtract("" + x)
def unapplySeq(x: Any): Option[(List[Int], Double, Seq[Char])] =
if ((x == null) || (x == "")) then None
else Some(new ThreeStringExtract("" + x).get)

This comment has been minimized.

Copy link
@nicolasstucki

nicolasstucki Dec 17, 2019

Contributor

Should add extra tests rather than modify the old ones

This comment has been minimized.

Copy link
@liufengyun

liufengyun Jan 14, 2020

Author Contributor

We added extra tests in other files. This test has to be adapted, as it does not conform to the protocol: the result type conforms to sequence match, thus it is irrefutable.

@@ -0,0 +1 @@
8: Pattern Match Exhaustivity: Foo(Nil)

This comment has been minimized.

Copy link
@nicolasstucki

nicolasstucki Dec 17, 2019

Contributor

Shouldn’t it be Pattern Match Exhaustivity: Foo()?

This comment has been minimized.

Copy link
@liufengyun

liufengyun Jan 14, 2020

Author Contributor

Now it prints Foo().

liufengyun added 10 commits Jul 12, 2019
The mismatch is caused by an additional ConstFold during unpickling.
Now if the result type of an unapplySeq conforms to a sequence match,
it will be taken as an irrefutable sequence match --- `isEmpty` and `get`
defined on the type are ignored. Thus, we need to rewrite the test.
It's accidentally removed in conflict resolution.
@liufengyun liufengyun force-pushed the dotty-staging:fix-6490 branch from bd4730f to 8ceb525 Jan 14, 2020
Copy link
Contributor Author

liufengyun left a comment

Updated

def unapplySeq(x: Any): ThreeStringExtract = new ThreeStringExtract("" + x)
def unapplySeq(x: Any): Option[(List[Int], Double, Seq[Char])] =
if ((x == null) || (x == "")) then None
else Some(new ThreeStringExtract("" + x).get)

This comment has been minimized.

Copy link
@liufengyun

liufengyun Jan 14, 2020

Author Contributor

We added extra tests in other files. This test has to be adapted, as it does not conform to the protocol: the result type conforms to sequence match, thus it is irrefutable.

@nicolasstucki nicolasstucki merged commit 376f5b0 into lampepfl:master Jan 16, 2020
2 checks passed
2 checks passed
CLA User signed CLA
Details
continuous-integration/drone/pr Build is passing
Details
@nicolasstucki nicolasstucki deleted the dotty-staging:fix-6490 branch Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.