fixed slice method
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@10044 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
6218a1e31c
commit
89da55b7d0
|
@ -128,13 +128,11 @@ abstract class TreePrinters {
|
|||
printTypeParams(tparams)
|
||||
print(" extends ");
|
||||
printRow(impl.parents, " with ")
|
||||
if (!impl.body.isEmpty) {
|
||||
print(" {");
|
||||
if (self.name != nme.WILDCARD) {
|
||||
print(" "); print(self.name); printOpt(": ", self.tpt); print(" => ")
|
||||
} else if (!self.tpt.isEmpty) {
|
||||
print(" _ : "); print(self); print(" => ")
|
||||
}
|
||||
print(" {");
|
||||
if (self.name != nme.WILDCARD) {
|
||||
print(" "); print(self.name); printOpt(": ", self.tpt); print(" => ")
|
||||
} else if (!self.tpt.isEmpty) {
|
||||
print(" _ : "); print(self.tpt); print(" => ")
|
||||
}
|
||||
printColumn(impl.body, "", ";", "}")
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ trait Trees requires Global {
|
|||
|
||||
def ValDef(sym: Symbol): ValDef = ValDef(sym, EmptyTree)
|
||||
|
||||
object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(), EmptyTree)
|
||||
object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree)
|
||||
|
||||
/** Method definition
|
||||
*
|
||||
|
|
|
@ -252,4 +252,12 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
|
|||
}
|
||||
result
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new BoxedAnyArray(len)
|
||||
Array.copy(this, start, result, 0, len)
|
||||
result
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,9 +72,6 @@ abstract class BoxedArray extends Seq[Any] {
|
|||
// todo: eliminate
|
||||
def subArray(from: Int, end: Int): AnyRef
|
||||
|
||||
override def slice(from: Int, end: Int): Seq[Object] =
|
||||
subArray(from, end).asInstanceOf[Seq[Object]]
|
||||
|
||||
final override def map[b](f: Any => b): Array[b] = {
|
||||
val len = length
|
||||
val result = new Array[b](len)
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray {
|
|||
}
|
||||
new BoxedBooleanArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Boolean](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedBooleanArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray {
|
|||
}
|
||||
new BoxedByteArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Byte](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedByteArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,4 +58,11 @@ final class BoxedCharArray(val value: Array[Char]) extends BoxedArray {
|
|||
}
|
||||
new BoxedCharArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Char](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedCharArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray {
|
|||
}
|
||||
new BoxedDoubleArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Double](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedDoubleArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray {
|
|||
}
|
||||
new BoxedFloatArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Float](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedFloatArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedIntArray(val value: Array[Int]) extends BoxedArray {
|
|||
}
|
||||
new BoxedIntArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Int](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedIntArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedLongArray(val value: Array[Long]) extends BoxedArray {
|
|||
}
|
||||
new BoxedLongArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Long](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedLongArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,4 +62,11 @@ final class BoxedObjectArray(val value: Array[AnyRef]) extends BoxedArray {
|
|||
}
|
||||
new BoxedObjectArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = create(len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedObjectArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,11 @@ final class BoxedShortArray(val value: Array[Short]) extends BoxedArray {
|
|||
}
|
||||
new BoxedShortArray(result)
|
||||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
val result = new Array[Short](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
new BoxedShortArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ scopes.scala:14: error: y is already defined as value y
|
|||
def f2(x: int)(y: int, y: float) = x + y
|
||||
^
|
||||
scopes.scala:15: error: x is already defined as value x
|
||||
(x: int, x: float) => x
|
||||
^
|
||||
val closure = (x: int, x: float) => x
|
||||
^
|
||||
scopes.scala:17: error: x is already defined as value x
|
||||
case x::x => x
|
||||
^
|
||||
|
|
|
@ -12,7 +12,7 @@ object test1 {
|
|||
}
|
||||
def f1(x: int, x: float) = x
|
||||
def f2(x: int)(y: int, y: float) = x + y
|
||||
(x: int, x: float) => x
|
||||
val closure = (x: int, x: float) => x
|
||||
List() match {
|
||||
case x::x => x
|
||||
case Nil => Nil
|
||||
|
|
Loading…
Reference in New Issue