This repository was archived by the owner on Sep 1, 2020. It is now read-only.
forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 19
Add flag to disable withFilter pattern desugaring #1
Merged
non
merged 6 commits into
typelevel:2.11.x
from
puffnfresh:feature/irrefutable-generator-patterns
Sep 24, 2014
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6302465
Add flag to disable withFilter pattern desugaring
puffnfresh 062e56c
Warn on non-exhaustive for-comprehension patterns
puffnfresh aceb216
Add a test for -Zirrefutable-generator-patterns
puffnfresh d7be78d
List Typelevel options when -Z flag is given
puffnfresh 7ac3809
Filter bincompat of ZirrefutableGeneratorPatterns
puffnfresh 5161c11
Merge branch '2.11.x-typelevel' into feature/irrefutable-generator-pa…
puffnfresh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -622,7 +622,7 @@ abstract class TreeGen { | |
body) setPos splitpos | ||
case None => | ||
atPos(splitpos) { | ||
mkVisitor(List(CaseDef(pat, EmptyTree, body)), checkExhaustive = false) | ||
mkVisitor(List(CaseDef(pat, EmptyTree, body)), checkExhaustive = settings.ZirrefutableGeneratorPatterns) | ||
} | ||
} | ||
} | ||
|
@@ -768,7 +768,7 @@ abstract class TreeGen { | |
} | ||
|
||
def mkCheckIfRefutable(pat: Tree, rhs: Tree)(implicit fresh: FreshNameCreator) = | ||
if (treeInfo.isVarPatternDeep(pat)) rhs | ||
if (treeInfo.isVarPatternDeep(pat) || settings.ZirrefutableGeneratorPatterns) rhs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a little bit too good to be true. Does the logic for detecting irrefutable patterns actually work and was just not applied properly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @larsrh: it appears this is not about detecting irrefutable patterns, it's about expecting them to be. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Blaisorblade exactly. Happy to clarify this if it's confusing somewhere. |
||
else { | ||
val cases = List( | ||
CaseDef(pat.duplicate, EmptyTree, Literal(Constant(true))), | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-Zirrefutable-generator-patterns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
case class Foo[A](a: A) { | ||
def map[B](f: A => B): Foo[B] = Foo(f(a)) | ||
def flatMap[B](f: A => Foo[B]): Foo[B] = Foo(f(a).a) | ||
} | ||
|
||
object Test { | ||
for { | ||
(a, b) <- Foo((1, 'd')) | ||
(c, d, e) <- Foo((1, true, "three")) | ||
} yield (a + c, e :+ b, !d) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupidly minor nitpick that probably isn't worth mentioning, but
for comprehensions
->for-comprehensions