Skip to content

Return Range.Exclusive on RichInt.until instead of abstract Range #8680

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

Closed
wants to merge 1 commit into from

Conversation

ausmarton
Copy link
Contributor

@ausmarton ausmarton commented Feb 2, 2020

Fixes scala/bug#11875

Shuffling an exclusive range of Ints created using until would fail in the block below as a result of the return type being an abstract type: Range, causing the Random.shuffle to look for an implicit of type: scala.collection.BuildFrom[Range, Int, _].

scala.util.Random.shuffle(1 to 10)

In addition, this change would also align the types which extend RangedProxy[T], namely: RichInt and IntegralProxy[T] in terms of their return types for .until. While IntegralProxy[T].until already returned a NumericRange.Exclusive[T], RichInt.until returned an abstract Range.

P.S.: This is my first PR here. Any feedback/suggestions are welcome and would be greatly appreciated. Thanks

@scala-jenkins scala-jenkins added this to the 2.13.3 milestone Feb 2, 2020
@ausmarton ausmarton changed the title Return Range.Exclusive on RichInt.until instead of abstract Range Fixes scala/bug#11875 Return Range.Exclusive on RichInt.until instead of abstract Range Feb 2, 2020
@ausmarton ausmarton changed the title Return Range.Exclusive on RichInt.until instead of abstract Range Return Range.Exclusive on RichInt.until instead of abstract Range Fixes scala/bug#11875 Feb 2, 2020
@ausmarton ausmarton changed the title Return Range.Exclusive on RichInt.until instead of abstract Range Fixes scala/bug#11875 Return Range.Exclusive on RichInt.until instead of abstract Range Feb 2, 2020
@ausmarton
Copy link
Contributor Author

/rebuild

@som-snytt
Copy link
Contributor

som-snytt commented Feb 2, 2020

This probably necessarily runs afoul of compatibility constraints:

[error] Saved log of library/mimaReportBinaryIssues:
[error]  * extension static method until$extension(Int,Int,Int)scala.collection.immutable.Range in 
class scala.runtime.RichInt has a different result type in current version, where it is 
scala.collection.immutable.Range#Exclusive rather than scala.collection.immutable.Range

@ausmarton
Copy link
Contributor Author

Thanks very much. It seems like the fix is going to be a bit more involved considering compatibility constraints.

@ausmarton ausmarton closed this Feb 2, 2020
@SethTisue SethTisue removed this from the 2.13.3 milestone Feb 4, 2020
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.

Cannot shuffle a Range, but can shuffle Range.Inclusive
4 participants