From 8aebc6c805851544a1b8e968d9ef6390298892e3 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 23 Jul 2012 17:04:16 +0200 Subject: SI-5933 do the new patmat translation for scaladoc especially because it benefits from nicer type inference for partial functions --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 43e1accec6..063f615e17 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -92,8 +92,8 @@ trait Typers extends Modes with Adaptations with Tags { // when true: // - we may virtualize matches (if -Xexperimental and there's a suitable __match in scope) // - we synthesize PartialFunction implementations for `x => x match {...}` and `match {...}` when the expected type is PartialFunction - // this is disabled by: -Xoldpatmat, scaladoc or interactive compilation - @inline private def newPatternMatching = opt.virtPatmat && !forScaladoc && !forInteractive // && (phase.id < currentRun.uncurryPhase.id) + // this is disabled by: -Xoldpatmat or interactive compilation (we run it for scaladoc due to SI-5933) + @inline private def newPatternMatching = opt.virtPatmat && !forInteractive //&& !forScaladoc && (phase.id < currentRun.uncurryPhase.id) abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tag with TyperContextErrors { import context0.unit -- cgit v1.2.3 From 36784d83dec93012e30254ba5207c59d868b613c Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Tue, 7 Aug 2012 21:36:45 +0200 Subject: SI-5933 testcase for Adriaan's pullreq #980 --- test/scaladoc/run/SI-5933.check | 1 + test/scaladoc/run/SI-5933.scala | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/scaladoc/run/SI-5933.check create mode 100644 test/scaladoc/run/SI-5933.scala diff --git a/test/scaladoc/run/SI-5933.check b/test/scaladoc/run/SI-5933.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-5933.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-5933.scala b/test/scaladoc/run/SI-5933.scala new file mode 100644 index 0000000000..087116fa71 --- /dev/null +++ b/test/scaladoc/run/SI-5933.scala @@ -0,0 +1,43 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + // Test code + override def code = """ + // This example should compile without errors, and the pattern match should be correctly displayed + + import language.higherKinds + + abstract class Base[M[_, _]] { + def foo[A, B]: M[(A, B), Any] + } + + class Derived extends Base[PartialFunction] { + def foo[A, B] /*: PartialFunction[(A, B) => Any]*/ = { case (a, b) => (a: A, b: B) } + } + + object Test { + lazy val lx = { println("hello"); 3 } + def test1(x: Int = lx) = ??? + def test2(x: Int = lx match { case 0 => 1; case 3 => 4 }) = ??? + } + """ + + // no need for special settings + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s)) + import access._ + + val Test = rootPackage._object("Test") + val test1 = Test._method("test1") + val test2 = Test._method("test2") + + def assertEqual(s1: String, s2: String) = assert(s1 == s2, s1 + " == " + s2) + + assertEqual(test1.valueParams(0)(0).defaultValue.get.expression, "lx") + assertEqual(test2.valueParams(0)(0).defaultValue.get.expression, "lx match { case 0 => 1; case 3 => 4 }") + } +} \ No newline at end of file -- cgit v1.2.3