From e313d9651adc2b7137a1dabbd3b0351619383035 Mon Sep 17 00:00:00 2001 From: Burak Emir Date: Tue, 21 Aug 2007 21:49:23 +0000 Subject: fixed #1281, reverted Sean's lazy generator in ... fixed #1281, reverted Sean's lazy generator in Main which broke the build --- src/compiler/scala/tools/nsc/Main.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 1 + test/files/run/patmatnew.scala | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index cf858409b2..e710487aa8 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -86,7 +86,7 @@ object Main extends AnyRef with EvalLoop { run compile command.files if (command.settings.doc.value) { object generator extends DocDriver { - lazy val global: compiler.type = compiler + /*lazy*/ val global: compiler.type = compiler def settings = command.settings } generator process run.units diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index c162eacc1d..ed796b9967 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1661,6 +1661,7 @@ trait Typers { self: Analyzer => val typer1 = new Typer(context1) arg.tpe = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe) //todo: replace arg with arg.asInstanceOf[inferTypedPattern(unappFormal, arg.tpe)] instead. + argDummy.setInfo(arg.tpe) // bq: this line fixed #1281. w.r.t. comment ^^^, maybe good enough? } val funPrefix = fun.tpe.prefix match { case tt @ ThisType(sym) => diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index f183fc11ec..14e349b847 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -394,5 +394,27 @@ object Test extends TestConsoleMain { } } + object cast2 { // #1281 + + 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) // the argDummy should have proper arg.tpe (Int in this case) + } + } + + println((new Buffer).jp.isDefinedAt(40)) + println((new Buffer).jp.isDefinedAt(42)) + } + } -- cgit v1.2.3