Skip to content

Fix broken .travis.yml #112

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 3 commits into from
Jul 23, 2018
Merged

Fix broken .travis.yml #112

merged 3 commits into from
Jul 23, 2018

Conversation

MasseGuillaume
Copy link
Contributor

@MasseGuillaume MasseGuillaume commented Jul 23, 2018

@julienrf it looks like the cross-compat breakOut PR was broken. I'm fixing it here. I'm also re-enabling CI.

@MasseGuillaume MasseGuillaume force-pushed the fix-build branch 3 times, most recently from a9efc2d to 3d7a37e Compare July 23, 2018 12:26
@MasseGuillaume
Copy link
Contributor Author

@julienrf ready for review, this one is important since it unblocks CI.


package object compat extends compat.PackageShared {
implicit def toImmutableSortedMapExtensions(fact: i.SortedMap.type): compat.ImmutableSortedMapExtensions =
new compat.ImmutableSortedMapExtensions(fact)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related with the PR description?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A previous PR was merged but was broken for 2.11. This fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR disable the CI: #109
This PR does not compile in Scala 2.11: #102

I'm splitting the package object into two parts: 2.11 and 2.12. I have to do this because mutable.TreeMap is only available since 2.11. The package object makes it hard to reuse code between 2.11 and 2.12.

@julienrf
Copy link
Contributor

julienrf commented Jul 23, 2018

Would it be possible to have the following?

// scala-2.11_2.12/CompatShared.scala
trait CompatShared {
  implicit class IterableFactoryExtensionMethods[CC[X] <: GenTraversable[X]](private val fact: GenericCompanion[CC]) {
    def from[A](source: TraversableOnce[A]): CC[A] =
      fact.apply(source.toSeq: _*)
  }
  // same for all other definitions that are compatible with 2.11 and 2.12
}

// scala-2.11/compat.scala
package object compat extends CompatShared

// scala-2.12/compat.scala
package object compat extends CompatShared {
  implicit class MutableTreeMapExtensions2(private val fact: m.TreeMap.type) extends AnyVal {
    def from[K: Ordering, V](source: TraversableOnce[(K, V)]): m.TreeMap[K, V] =
      build(m.TreeMap.newBuilder[K, V], source)
  }
  // same with all 2.12 specific definitions
}

So that there is no duplication between scala-2.11 and scala-2.12?

@MasseGuillaume
Copy link
Contributor Author

You suggest dropping the AnyVal ?

@julienrf
Copy link
Contributor

No, you’re right we should keep extending AnyVal. But we can do it in a way that doesn’t require code duplication between 2.11 and 2.12:

// scala-2.11_2.12
trait CompatShared {
  implicit def sharedExtensions(receiver: Foo): FooExtensions = new CompatShared.FooExtensions(receiver)
}
object CompatShared {
  class FooExtensions(private val receiver: Foo) extends AnyVal {
    // some extension methods…
  }
}

// scala-2.11
package object compat extends CompatShared

// scala-2.12
package object compat extends CompatShared {
  // more extension methods that are specific to scala 2.12
}

@MasseGuillaume
Copy link
Contributor Author

Oh, of course, nice catch.

mutable.TreeMap and mutable.ListMap are not available in 2.11. It's
not possible to put implicit classes in a shared trait. We have to duplicate
a bit the api
@MasseGuillaume
Copy link
Contributor Author

@julienrf done, rebased.

@MasseGuillaume
Copy link
Contributor Author

@julienrf ci is green.

@julienrf julienrf merged commit 6afea84 into scala:master Jul 23, 2018
martijnhoekstra pushed a commit to martijnhoekstra/scala-collection-compat that referenced this pull request Nov 9, 2022
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