Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ trait ScalaSettings extends AbsScalaSettings

private def removalIn212 = "This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug."

/**
* -Z Typelevel settings
*/
val ZirrefutableGeneratorPatterns = BooleanSetting("-Zirrefutable-generator-patterns", "Treat patterns in for comprehensions as irrefutable. Do not add filter or withFilter calls.")
Copy link

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


/** Area-specific debug output.
*/
val Ydocdebug = BooleanSetting("-Ydoc-debug", "Trace all scaladoc activity.")
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/TreeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The 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?

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ abstract class MutableSettings extends AbsSettings {
def maxClassfileName: IntSetting

def isScala211: Boolean

def ZirrefutableGeneratorPatterns: BooleanSetting
}

object MutableSettings {
Expand Down
2 changes: 2 additions & 0 deletions src/reflect/scala/reflect/runtime/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ private[reflect] class Settings extends MutableSettings {
val Yrecursion = new IntSetting(0)
val maxClassfileName = new IntSetting(255)
def isScala211 = true

def ZirrefutableGeneratorPatterns = new BooleanSetting(false)
}