| [#1213] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Iulian | Burak | fixed | 2007-07-16 13:17:03.0 | |
| subject | Pattern matching on constructor parameters crashes the compiler | |||
| code |
abstract class MapLocation(ID:int) {
abstract class Message
case class ReceivePlayer(id: int) extends Message
def foo(p: Message) {
p match {
case ReceivePlayer(ID) =>
()
}
}
}
|
|||
| what happened | 'foo' is translated to something like:
if (scala.Int.box(temp5.$asInstanceOf[MapLocation$ReceivePlayer]().id())
.equals(scala.Int.box(scala.this.$asInstanceOf[MapLocation]().ID1)))
()
else
throw new MatchError(temp5)
Besides comparing ints by first boxing them, a strange piece of code is "scala.this.$asInstanceOf[MapLocation]()\
.ID1", which casts the scala package to something.
Making 'ID' a proper valdef in the class instead of a constructor parameter makes the compiler happy.
|
|||
| what expected | No error. | |||
| [back to overview] | ||||
| Burak edited on 2007-08-14 18:11:30.0 |