Skip to content

Commit d4c8c3b

Browse files
authored
Add support for Scala 2.11 (#5)
* Add support for Scala 2.11 Fixes #1
1 parent 29e1971 commit d4c8c3b

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

build.sbt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ name := "scala-collection-compat"
44

55
version := "0.1-SNAPSHOT"
66

7-
unmanagedSourceDirectories in Compile ++=
8-
(if(scalaVersion.value.startsWith("2.13.")) Seq((sourceDirectory in Compile).value / "scala-2.13") else Seq())
7+
resolvers += "scala-pr" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
98

10-
crossScalaVersions := Seq("2.12.4", "2.13.0-M4-pre-20d3c21")
9+
unmanagedSourceDirectories in Compile += (
10+
if(scalaVersion.value.startsWith("2.13.")) (sourceDirectory in Compile).value / "scala-2.13"
11+
else (sourceDirectory in Compile).value / "scala-2.11_2.12"
12+
)
13+
14+
crossScalaVersions := Seq("2.12.5", "2.13.0-M4-pre-20d3c21", "2.11.12")
1115

1216
scalaVersion := crossScalaVersions.value.head
1317

src/main/scala-2.12/collection/immutable/ImmutableArray.scala renamed to src/main/scala-2.11_2.12/collection/immutable/ImmutableArray.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ object ImmutableArray {
9494
final class ofRef[T <: AnyRef](val unsafeArray: Array[T]) extends ImmutableArray[T] with Serializable {
9595
lazy val elemTag = ClassTag[T](unsafeArray.getClass.getComponentType)
9696
def length: Int = unsafeArray.length
97-
def apply(index: Int): T = unsafeArray(index).asInstanceOf[T]
97+
def apply(index: Int): T = unsafeArray(index)
9898
def update(index: Int, elem: T) { unsafeArray(index) = elem }
99-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
99+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
100100
override def equals(that: Any) = that match {
101101
case that: ofRef[_] => Arrays.equals(unsafeArray.asInstanceOf[Array[AnyRef]], that.unsafeArray.asInstanceOf[Array[AnyRef]])
102102
case _ => super.equals(that)
@@ -108,7 +108,7 @@ object ImmutableArray {
108108
def length: Int = unsafeArray.length
109109
def apply(index: Int): Byte = unsafeArray(index)
110110
def update(index: Int, elem: Byte) { unsafeArray(index) = elem }
111-
override def hashCode = MurmurHash3.wrappedBytesHash(unsafeArray)
111+
override def hashCode = MurmurHash3.bytesHash(unsafeArray, MurmurHash3.seqSeed)
112112
override def equals(that: Any) = that match {
113113
case that: ofByte => Arrays.equals(unsafeArray, that.unsafeArray)
114114
case _ => super.equals(that)
@@ -120,7 +120,7 @@ object ImmutableArray {
120120
def length: Int = unsafeArray.length
121121
def apply(index: Int): Short = unsafeArray(index)
122122
def update(index: Int, elem: Short) { unsafeArray(index) = elem }
123-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
123+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
124124
override def equals(that: Any) = that match {
125125
case that: ofShort => Arrays.equals(unsafeArray, that.unsafeArray)
126126
case _ => super.equals(that)
@@ -132,7 +132,7 @@ object ImmutableArray {
132132
def length: Int = unsafeArray.length
133133
def apply(index: Int): Char = unsafeArray(index)
134134
def update(index: Int, elem: Char) { unsafeArray(index) = elem }
135-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
135+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
136136
override def equals(that: Any) = that match {
137137
case that: ofChar => Arrays.equals(unsafeArray, that.unsafeArray)
138138
case _ => super.equals(that)
@@ -144,7 +144,7 @@ object ImmutableArray {
144144
def length: Int = unsafeArray.length
145145
def apply(index: Int): Int = unsafeArray(index)
146146
def update(index: Int, elem: Int) { unsafeArray(index) = elem }
147-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
147+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
148148
override def equals(that: Any) = that match {
149149
case that: ofInt => Arrays.equals(unsafeArray, that.unsafeArray)
150150
case _ => super.equals(that)
@@ -156,7 +156,7 @@ object ImmutableArray {
156156
def length: Int = unsafeArray.length
157157
def apply(index: Int): Long = unsafeArray(index)
158158
def update(index: Int, elem: Long) { unsafeArray(index) = elem }
159-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
159+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
160160
override def equals(that: Any) = that match {
161161
case that: ofLong => Arrays.equals(unsafeArray, that.unsafeArray)
162162
case _ => super.equals(that)
@@ -168,7 +168,7 @@ object ImmutableArray {
168168
def length: Int = unsafeArray.length
169169
def apply(index: Int): Float = unsafeArray(index)
170170
def update(index: Int, elem: Float) { unsafeArray(index) = elem }
171-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
171+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
172172
override def equals(that: Any) = that match {
173173
case that: ofFloat => Arrays.equals(unsafeArray, that.unsafeArray)
174174
case _ => super.equals(that)
@@ -180,7 +180,7 @@ object ImmutableArray {
180180
def length: Int = unsafeArray.length
181181
def apply(index: Int): Double = unsafeArray(index)
182182
def update(index: Int, elem: Double) { unsafeArray(index) = elem }
183-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
183+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
184184
override def equals(that: Any) = that match {
185185
case that: ofDouble => Arrays.equals(unsafeArray, that.unsafeArray)
186186
case _ => super.equals(that)
@@ -192,7 +192,7 @@ object ImmutableArray {
192192
def length: Int = unsafeArray.length
193193
def apply(index: Int): Boolean = unsafeArray(index)
194194
def update(index: Int, elem: Boolean) { unsafeArray(index) = elem }
195-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
195+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
196196
override def equals(that: Any) = that match {
197197
case that: ofBoolean => Arrays.equals(unsafeArray, that.unsafeArray)
198198
case _ => super.equals(that)
@@ -204,7 +204,7 @@ object ImmutableArray {
204204
def length: Int = unsafeArray.length
205205
def apply(index: Int): Unit = unsafeArray(index)
206206
def update(index: Int, elem: Unit) { unsafeArray(index) = elem }
207-
override def hashCode = MurmurHash3.wrappedArrayHash(unsafeArray)
207+
override def hashCode = MurmurHash3.arrayHash(unsafeArray, MurmurHash3.seqSeed)
208208
override def equals(that: Any) = that match {
209209
case that: ofUnit => unsafeArray.length == that.unsafeArray.length
210210
case _ => super.equals(that)

0 commit comments

Comments
 (0)