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

Improve escape hatch for filter in generator #7525

Closed
wants to merge 1 commit into from

Conversation

som-snytt
Copy link
Contributor

Allow for (x @ (_: T) <- ts) workaround using
underscore as shown. Because the rewrite happens
after patterns are transformed, it was taken as
a straight typed pattern.

@som-snytt
Copy link
Contributor Author

The failing test is roundtripping in quasiquotes, which doesn't understand the partial function with Tuple1 decomposition.

Currently:

$ scalam
Welcome to Scala 2.13.0-M5 (OpenJDK 64-Bit Server VM, Java 1.8.0_191).
Type in expressions for evaluation. Or try :help.

scala> import reflect.runtime._,universe._
import reflect.runtime._
import universe._

scala> q"""for (x @ (y: String) <- List("")) yield x"""
res0: reflect.runtime.universe.Tree =
List("").withFilter(((check$ifrefutable$1) => check$ifrefutable$1: @scala.unchecked match {
  case (x @ (y @ (_: String))) => true
  case _ => false
})).withFilter(((check$ifrefutable$2) => check$ifrefutable$2: @scala.unchecked match {
  case (x @ (y @ (_: String))) => true
  case _ => false
})).map(((x$1) => x$1: @scala.unchecked match {
  case (x @ (y @ (_: String))) => x
}))

scala> for (x @ (y: String) <- List("")) yield x //print

scala.collection.immutable.List.apply[String]("").withFilter(((check$ifrefutable$1: String) => (check$ifrefutable$1: @scala.unchecked) match {
  case (x @ (y @ ((_): scala.Predef.String))) => true
  case _ => false
})).map[String](((x$1: String) => (x$1: @scala.unchecked) match {
  case (x @ (y @ ((_): scala.Predef.String))) => x
})) // : List[String]

@som-snytt som-snytt closed this Jan 20, 2019
@som-snytt som-snytt deleted the issue/900-workaround branch January 20, 2019 14:38
@SethTisue SethTisue removed this from the 2.13.0-RC1 milestone Feb 22, 2019
Allow `for (x @ (_: T) <- ts)` workaround using
underscore as shown. Because the rewrite happens
after patterns are transformed, it was taken as
a straight typed pattern.
@som-snytt som-snytt restored the issue/900-workaround branch October 31, 2020 18:25
@som-snytt som-snytt reopened this Oct 31, 2020
@scala-jenkins scala-jenkins added this to the 2.13.5 milestone Oct 31, 2020
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Oct 31, 2020
@som-snytt
Copy link
Contributor Author

som-snytt commented Oct 31, 2020

Reviving to add pattern improvements under -Xsource:3, to support case in for, and also @unchecked ascription. Currently, lint of refutable pattern in vardef requires @unchecked on the rhs.

Jenkins, would you let me know which test was failing? My branch had a bunch of debug added for quasiquotes, but no test. ("Scalacheck tests.")

@som-snytt
Copy link
Contributor Author

som-snytt commented Nov 6, 2020

Would be nice to support implicit val _: Int = 42 (i.e., fresh name) under -Xsource:3.

And warn List(1,2,3).map { i: Int => i + 1 } (issue 12218)

@som-snytt som-snytt self-assigned this Dec 4, 2020
@som-snytt
Copy link
Contributor Author

Closing for indifference.

@som-snytt som-snytt closed this Dec 4, 2020
@SethTisue
Copy link
Member

SethTisue commented Dec 5, 2020

whose indifference? I'm not indifferent! (I think @dwijnand isn't either...?)

to be clear, I'm not claiming my non-indifference was externally observable

aligning with Scala 3 here, insofar as it proves to be possible, seems appealing

@SethTisue SethTisue removed this from the 2.13.5 milestone Dec 5, 2020
@dwijnand
Copy link
Member

dwijnand commented Dec 7, 2020

I think we should implement Scala 3's escape hatch rather than our own. So I'm not indifferent (I'm different) on the what but I'm not in favour of the how here. Unless I'm missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
4 participants