Aladdin - Scala Bugtracking
[#795] project: compiler priority: low category: bug
submitter assigned to status date submitted
Martin Burak fixed 2006-11-03 17:48:38.0
subject unapply problem in erasure
code
  object Twice {
    def apply(x: int) = x * 2
    def unapply(x: int): Option[Tuple1[int]] =
      if (x % 2 == 0) Some(Tuple1(x / 2))
      else None
  }

object Test extends Application {

  def test(x: int) = x match {
    case Twice(y) => "x is two times "+y
    case _ => "x is odd"
  }

  Console.println(test(3))
  Console.println(test(4))

}
what happened
java.lang.AssertionError: assertion failed: method get
	at scala.Predef$.assert(Predef.scala:100)
	at scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:380)
	at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:398)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2106)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1953)
	at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:398)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2106)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:1214)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$51.apply(Typers.scala:1231)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$51.apply(Typers.scala:1231)
	at scala.List$.map2(List.scala:271)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArgs(Typers.scala:1231)
	at scala.tools.nsc.typechecker.Typers$Typer.typedApply(Typers.scala:1258)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1964)
	at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:398)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2106)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:1214)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$51.apply(Typers.scala:1231)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$51.apply(Typers
what expected I think the call to get must be wrapped in an Apply(get, ()).
[back to overview]
Changes of this bug report
Burak  edited on  2006-11-10 19:01:51.0
it was the call to the typer that was missing