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

j.l.String.lines (introduced JDK 11) trumps StringOps.lines #557

Closed
retronym opened this issue Sep 10, 2018 · 1 comment
Closed

j.l.String.lines (introduced JDK 11) trumps StringOps.lines #557

retronym opened this issue Sep 10, 2018 · 1 comment
Labels
Milestone

Comments

@retronym
Copy link
Member

$ scala
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 11-ea).
Type in expressions for evaluation. Or try :help.

scala> "".lines.toList
<console>:12: error: value toList is not a member of java.util.stream.Stream[String]
       "".lines.toList
                ^

scala> augmentString("").lines.toList
res1: List[String] = List()

scala> ("": collection.immutable.StringOps).lines.toList
res2: List[String] = List()

scala> "".linesIterator.toList
<console>:12: warning: method linesIterator in trait StringLike is deprecated (since 2.11.0): use `lines` instead
       "".linesIterator.toList
          ^
res3: List[String] = List()

I propose that we undeprecate linesIterator in 2.12, and restore it to 2.13 (where it was already removed).

@dwijnand
Copy link
Member

Duplicate of scala/bug#11125

@dwijnand dwijnand marked this as a duplicate of scala/bug#11125 Sep 10, 2018
diesalbla added a commit to scala/scala that referenced this issue Aug 21, 2019
Java 11 introduced a `lines` method to the String class, which 
has precedence over the `lines` extension method added by StringOps.
As a result, the code using that method was failing to compile. 
This PR repairs that by using `linesIterator` instead.
    
See scala/scala-dev#557 for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants