Aladdin - Scala Bugtracking
[#1281] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Philipp Burak fixed 2007-08-20 20:15:56.0
subject unapplySeq crashes compiler when argument is not Any
code
package test

object cast2 extends Application {

  class Sync {
    def unapplySeq(scrut: Int): Option[Seq[Int]] = {
      println("unapplySeq: "+scrut)
      if (scrut == 42) Some(List(1, 2))
      else None
    }
  }

  class Buffer {
    val Get = new Sync

    val jp: PartialFunction[Any, Any] = {
      case Get(xs) => println(xs)
    }
  }

  println((new Buffer).jp.isDefinedAt(40))
  println((new Buffer).jp.isDefinedAt(42))
}
what happened
exception when traversing ((x$0: Any) => x$0 match {
  case Buffer.this.Get.unapplySeq()  ((xs @ _)) => scala.this.Predef.println(xs)
})
...

Exception in thread "main" scala.tools.nsc.symtab.Types$TypeError: type mismatch;
 found   : Any
 required: Int
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:283)
        at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:218)
        at scala.tools.nsc.typechecker.Infer$Inferencer.typeError(Infer.scala:228)
        at scala.tools.nsc.typechecker.Infer$Inferencer.typeErrorTree(Infer.scala:234)
        at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:770)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2933)
        at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:1489)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$63.apply(Typers.scala:1505)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$63.apply(Typers.scala:1505)
        at scala.List$.map2(List.scala:277)
        at scala.tools.nsc.typechecker.Typers$Typer.typedArgs(Typers.scala:1505)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:1559)
        at scala.tools.nsc.typechecker.Typers$Typer.typedApply$0(Typers.scala:2267)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2827)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2931)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2964)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2714)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2931)
        at scala.tools.nsc.typechecker.Typers$Typer.typedPattern(Typers.scala:2992)
        at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:1321)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$50.apply(Typers.scala:1353)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$50.apply(Typers.scala:1352)
        at scala.List$.loop$0(List.scala:244)
        at scala.List$.mapConserve(List.scala:261)
        at scala.tools.nsc.typechecker.Typers$Typer.typedCases(Typers.scala:1352)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2744)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2931)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2975)
        at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:3024)
        at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1233)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2670)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2931)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2964)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1455)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:1485)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:1485)
        at scala.List$.loop$0(List.scala:244)
        at scala.List$.mapConserve(List.scala:261)
        at scala.List$.loop$0(List.scala:248)
        at scala.List$.mapConserve(List.scala:261)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1485)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1103)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:989)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2661)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2931)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2964)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1455)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:1485)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:1485)
        at scala.List$.loop$0(List.scala:244)
        at scala.List$.mapConserve(List.scala:261)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1485)
        at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:1306)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2694)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2931)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2964)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transformFunction(UnCurry.scala:306)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:466)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:106)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$23.apply(Trees.scala:1217)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$23.apply(Trees.scala:1217)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1333)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:33)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:27)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:1216)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:46)\

        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.scala$tools$nsc$transform$UnCurry$UnCurryTransfo\
rmer$$super$transform(UnCurry.scala:394)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$8.apply(UnCurry.scala:400)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$8.apply(UnCurry.scala:400)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNeedLift$0(UnCurry.scala:364)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:400)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:106)
...
what expected Compile without error.
[back to overview]
Changes of this bug report
Burak  edited on  2007-08-21 23:50:30.0
argDummy symbol is now given a proper info