@@ -29,15 +29,6 @@ object ScalaRunTime {
2929 private def isArrayClass (clazz : jClass[_], atLevel : Int ): Boolean =
3030 clazz.isArray && (atLevel == 1 || isArrayClass(clazz.getComponentType, atLevel - 1 ))
3131
32- def isValueClass (clazz : jClass[_]) = clazz.isPrimitive()
33-
34- // includes specialized subclasses and future proofed against hypothetical TupleN (for N > 22)
35- def isTuple (x : Any ) = x != null && x.getClass.getName.startsWith(" scala.Tuple" )
36- def isAnyVal (x : Any ) = x match {
37- case _ : Byte | _ : Short | _ : Char | _ : Int | _ : Long | _ : Float | _ : Double | _ : Boolean | _ : Unit => true
38- case _ => false
39- }
40-
4132 // A helper method to make my life in the pattern matcher a lot easier.
4233 def drop [Repr ](coll : Repr , num : Int )(implicit traversable : IsTraversableLike [Repr ]): Repr =
4334 traversable conversion coll drop num
@@ -50,15 +41,6 @@ object ScalaRunTime {
5041 else java.lang.reflect.Array .newInstance(clazz, 0 ).getClass
5142 }
5243
53- /** Return the class object representing elements in arrays described by a given schematic.
54- */
55- def arrayElementClass (schematic : Any ): jClass[_] = schematic match {
56- case cls : jClass[_] => cls.getComponentType
57- case tag : ClassTag [_] => tag.runtimeClass
58- case _ =>
59- throw new UnsupportedOperationException (s " unsupported schematic $schematic ( ${schematic.getClass}) " )
60- }
61-
6244 /** Return the class object representing an unboxed value type,
6345 * e.g., classOf[int], not classOf[java.lang.Integer]. The compiler
6446 * rewrites expressions like 5.getClass to come here.
@@ -116,15 +98,15 @@ object ScalaRunTime {
11698 }
11799
118100 def array_clone (xs : AnyRef ): AnyRef = xs match {
119- case x : Array [AnyRef ] => ArrayRuntime .cloneArray(x )
120- case x : Array [Int ] => ArrayRuntime .cloneArray(x )
121- case x : Array [Double ] => ArrayRuntime .cloneArray(x )
122- case x : Array [Long ] => ArrayRuntime .cloneArray(x )
123- case x : Array [Float ] => ArrayRuntime .cloneArray(x )
124- case x : Array [Char ] => ArrayRuntime .cloneArray(x )
125- case x : Array [Byte ] => ArrayRuntime .cloneArray(x )
126- case x : Array [Short ] => ArrayRuntime .cloneArray(x )
127- case x : Array [Boolean ] => ArrayRuntime .cloneArray(x )
101+ case x : Array [AnyRef ] => x.clone( )
102+ case x : Array [Int ] => x.clone( )
103+ case x : Array [Double ] => x.clone( )
104+ case x : Array [Long ] => x.clone( )
105+ case x : Array [Float ] => x.clone( )
106+ case x : Array [Char ] => x.clone( )
107+ case x : Array [Byte ] => x.clone( )
108+ case x : Array [Short ] => x.clone( )
109+ case x : Array [Boolean ] => x.clone( )
128110 case x : Array [Unit ] => x
129111 case null => throw new NullPointerException
130112 }
@@ -157,9 +139,6 @@ object ScalaRunTime {
157139 // More background at ticket #2318.
158140 def ensureAccessible (m : JMethod ): JMethod = scala.reflect.ensureAccessible(m)
159141
160- def checkInitialized [T <: AnyRef ](x : T ): T =
161- if (x == null ) throw new UninitializedError else x
162-
163142 def _toString (x : Product ): String =
164143 x.productIterator.mkString(x.productPrefix + " (" , " ," , " )" )
165144
@@ -179,72 +158,12 @@ object ScalaRunTime {
179158 }
180159 }
181160
182- /** Fast path equality method for inlining; used when -optimise is set.
183- */
184- @ inline def inlinedEquals (x : Object , y : Object ): Boolean =
185- if (x eq y) true
186- else if (x eq null ) false
187- else if (x.isInstanceOf [java.lang.Number ]) BoxesRunTime .equalsNumObject(x.asInstanceOf [java.lang.Number ], y)
188- else if (x.isInstanceOf [java.lang.Character ]) BoxesRunTime .equalsCharObject(x.asInstanceOf [java.lang.Character ], y)
189- else x.equals(y)
190-
191- def _equals (x : Product , y : Any ): Boolean = y match {
192- case y : Product if x.productArity == y.productArity => x.productIterator sameElements y.productIterator
193- case _ => false
194- }
195-
196- // hashcode -----------------------------------------------------------
197- //
198- // Note that these are the implementations called by ##, so they
199- // must not call ## themselves.
200-
161+ /** Implementation of `##`. */
201162 def hash (x : Any ): Int =
202163 if (x == null ) 0
203164 else if (x.isInstanceOf [java.lang.Number ]) BoxesRunTime .hashFromNumber(x.asInstanceOf [java.lang.Number ])
204165 else x.hashCode
205166
206- def hash (dv : Double ): Int = {
207- val iv = dv.toInt
208- if (iv == dv) return iv
209-
210- val lv = dv.toLong
211- if (lv == dv) return lv.hashCode
212-
213- val fv = dv.toFloat
214- if (fv == dv) fv.hashCode else dv.hashCode
215- }
216- def hash (fv : Float ): Int = {
217- val iv = fv.toInt
218- if (iv == fv) return iv
219-
220- val lv = fv.toLong
221- if (lv == fv) hash(lv)
222- else fv.hashCode
223- }
224- def hash (lv : Long ): Int = {
225- val low = lv.toInt
226- val lowSign = low >>> 31
227- val high = (lv >>> 32 ).toInt
228- low ^ (high + lowSign)
229- }
230- def hash (x : Number ): Int = runtime.BoxesRunTime .hashFromNumber(x)
231-
232- // The remaining overloads are here for completeness, but the compiler
233- // inlines these definitions directly so they're not generally used.
234- def hash (x : Int ): Int = x
235- def hash (x : Short ): Int = x.toInt
236- def hash (x : Byte ): Int = x.toInt
237- def hash (x : Char ): Int = x.toInt
238- def hash (x : Boolean ): Int = if (x) true .hashCode else false .hashCode
239- def hash (x : Unit ): Int = 0
240-
241- /** A helper method for constructing case class equality methods,
242- * because existential types get in the way of a clean outcome and
243- * it's performing a series of Any/Any equals comparisons anyway.
244- * See ticket #2867 for specifics.
245- */
246- def sameElements (xs1 : scala.collection.Seq [Any ], xs2 : scala.collection.Seq [Any ]) = xs1 sameElements xs2
247-
248167 /** Given any Scala value, convert it to a String.
249168 *
250169 * The primary motivation for this method is to provide a means for
@@ -266,6 +185,9 @@ object ScalaRunTime {
266185 def isScalaClass (x : AnyRef ) = packageOf(x) startsWith " scala."
267186 def isScalaCompilerClass (x : AnyRef ) = packageOf(x) startsWith " scala.tools.nsc."
268187
188+ // includes specialized subclasses and future proofed against hypothetical TupleN (for N > 22)
189+ def isTuple (x : Any ) = x != null && x.getClass.getName.startsWith(" scala.Tuple" )
190+
269191 // We use reflection because the scala.xml package might not be available
270192 def isSubClassOf (potentialSubClass : Class [_], ofClass : String ) =
271193 try {
@@ -345,17 +267,4 @@ object ScalaRunTime {
345267
346268 nl + s + " \n "
347269 }
348-
349- def box [T ](clazz : jClass[T ]): jClass[_] = clazz match {
350- case java.lang.Byte .TYPE => classOf [java.lang.Byte ]
351- case java.lang.Short .TYPE => classOf [java.lang.Short ]
352- case java.lang.Character .TYPE => classOf [java.lang.Character ]
353- case java.lang.Integer .TYPE => classOf [java.lang.Integer ]
354- case java.lang.Long .TYPE => classOf [java.lang.Long ]
355- case java.lang.Float .TYPE => classOf [java.lang.Float ]
356- case java.lang.Double .TYPE => classOf [java.lang.Double ]
357- case java.lang.Void .TYPE => classOf [scala.runtime.BoxedUnit ]
358- case java.lang.Boolean .TYPE => classOf [java.lang.Boolean ]
359- case _ => clazz
360- }
361270}
0 commit comments