| [#46] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Stephane | Martin | won't fix | 2003-06-19 22:25:47.0 | |
| subject | type mismatch | |||
| code |
object Main {
case class IntBox(x: Int) {
override def toString() = x.toString();
}
def Array[Int](x: Int*): Int = {
val xs = x as List[Int];
val ar = new java.util.ArrayList(xs.length);
xs foreach ( x: Int => { ar.add(IntBox(x)); () } );
0
}
def main(args: Array[String]) = {
val xs = List(2, 3, 7, 1, 5);
val ar = new java.util.ArrayList(xs.length);
xs foreach ( x => { ar.add(IntBox(x)); () } );
System.out.println(ar);
}
} |
|||
| what happened | src/Main.scala:11: type mismatch;
found : Int
required: scala.Int
xs foreach ( x: Int => { ar.add(IntBox(x)); () } );
^
src/Main.scala:12: type mismatch;
found : scala.Int
required: Int
0
^
two errors found
|
|||
| what expected | [2, 3, 7, 1, 5] is displayed on the console
Matthias: The error message is okay since Int is a type variable in the context of method Array which is different from the type scala.Int. |
|||
| [back to overview] | ||||