Skip to content

SI-7715 String inpatternation s"$_" for s"${_}" #2823

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
merged 1 commit into from
Aug 16, 2013

Conversation

som-snytt
Copy link
Contributor

In a pattern,

scala> implicit class RX(val sc: StringContext) {
     | def rx = sc.parts.mkString("(.+)").r }
defined class RX

scala> "2 by 4" match { case rx"$a by $_" => a }
res0: String = 2

scala> val rx"$_ by $b" = "2 by 4"
b: String = 4

In a pattern,

```
scala> implicit class RX(val sc: StringContext) {
     | def rx = sc.parts.mkString("(.+)").r }
defined class RX

scala> "2 by 4" match { case rx"$a by $_" => a }
res0: String = 2

scala> val rx"$_ by $b" = "2 by 4"
b: String = 4
```
@adriaanm
Copy link
Contributor

Oh boy.... How can this happen?

This one appears here and in #2821:

fail - pos/t7690.scala  [compilation failed]% scalac t7690.scala
error: the result type of an implicit conversion must be more specific than AnyRef
one error found

This one, only here:

fail - scalacheck/CheckCollections.scala  [compilation failed]% scalac CheckCollections.scala
CheckCollections.scala:22: error: not found: value map2Conserve
    val res = map2Conserve(xs, ys)(testid)
              ^
CheckCollections.scala:27: error: not found: value map2Conserve
    map2Conserve(xs, ys)(testid)  == map2ConserveOld(xs, ys)(testid) &&
    ^
CheckCollections.scala:11: error: not found: value map2Conserve
      val xs1 = map2Conserve(xs.tail, ys.tail)(f)
                ^
CheckCollections.scala:38: error: not found: value map2Conserve
    map2Conserve(xs, ys){ case(x, y) => x.toLowerCase + y.toString }
    ^
four errors found

@adriaanm
Copy link
Contributor

LGTM -- awesome!

adriaanm added a commit that referenced this pull request Aug 16, 2013
SI-7715 String inpatternation s"$_" for s"${_}"
@adriaanm adriaanm merged commit 01f2c2a into scala:master Aug 16, 2013
@som-snytt som-snytt deleted the issue/7715 branch May 27, 2014 12:12
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