summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-03-19 14:18:43 +0000
committerMartin Odersky <odersky@gmail.com>2007-03-19 14:18:43 +0000
commitcb08c06766425cc18aee02a0ebc0ccd395a5ed5f (patch)
tree988c16339f3d782e1ac28cd854d041c4149bd71f
parent3ee224f431b2563391e148d2a954d52308b67192 (diff)
downloadscala-cb08c06766425cc18aee02a0ebc0ccd395a5ed5f.tar.gz
scala-cb08c06766425cc18aee02a0ebc0ccd395a5ed5f.tar.bz2
scala-cb08c06766425cc18aee02a0ebc0ccd395a5ed5f.zip
added method round to RichFloat/RichDouble;
fixed bug 1008
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala3
-rw-r--r--src/library/scala/runtime/RichDouble.scala2
-rw-r--r--src/library/scala/runtime/RichFloat.scala2
4 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index d368ff37f5..66bdf9dfd1 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1042,7 +1042,10 @@ trait Types requires SymbolTable {
def transform(cl: Array[Type]): Array[Type] = {
val cl1 = new Array[Type](cl.length)
var i = 0
- while (i < cl.length) { cl1(i) = transform(cl(i)); i = i + 1 }
+ while (i < cl.length) {
+ cl1(i) = transform(cl(i))
+ i = i + 1
+ }
cl1
}
@@ -1789,7 +1792,9 @@ trait Types requires SymbolTable {
else subst(sym, from.tail, to.tail)
tp match {
case TypeRef(NoPrefix, sym, _) =>
- subst(sym, from, to)
+ val tp1 = subst(sym, from, to)
+ if (tp1 ne tp) tp1
+ else mapOver(tp)
case SingleType(NoPrefix, sym) =>
subst(sym, from, to)
case PolyType(tparams, restp) =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index ab4cf811fa..3ffb1e10bf 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1426,7 +1426,10 @@ trait Typers requires Analyzer {
}
fun.tpe match {
case OverloadedType(pre, alts) =>
+ val undetparams = context.undetparams
+ context.undetparams = List()
val args1 = typedArgs(args, mode)
+ context.undetparams = undetparams
inferMethodAlternative(fun, context.undetparams, args1 map (.tpe.deconst), pt)
typedApply(tree, adapt(fun, funMode(mode), WildcardType), args1, mode, pt)
case MethodType(formals0, restpe) =>
diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala
index 8db1fd6b35..c4bd0c589f 100644
--- a/src/library/scala/runtime/RichDouble.scala
+++ b/src/library/scala/runtime/RichDouble.scala
@@ -24,6 +24,8 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] {
def max(y: Double): Double = Math.max(x, y)
def abs: Double = Math.abs(x)
+ def round: Long = Math.round(x)
+
// isNaN is provided by the implicit conversion to java.lang.Double
// def isNaN: Boolean = java.lang.Double.isNaN(x)
def isInfinity: Boolean = java.lang.Double.isInfinite(x)
diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala
index 8c6a3f6523..3a65b7443b 100644
--- a/src/library/scala/runtime/RichFloat.scala
+++ b/src/library/scala/runtime/RichFloat.scala
@@ -24,6 +24,8 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] {
def max(y: Float) = Math.max(x, y)
def abs: Float = Math.abs(x)
+ def round: int = Math.round(x)
+
// isNaN is provided by the implicit conversion to java.lang.Float
// def isNaN: Boolean = java.lang.Float.isNaN(x)
def isInfinity: Boolean = java.lang.Float.isInfinite(x)