From 2890714d7bcdd55b7a62091dcdf031cc3efe0822 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 24 Apr 2012 15:59:58 +0200 Subject: generate well-formed patterns in parser val pattern: Type = expr desugared to val x = expr match { case pattern: Type => (var_1, ..., var_N)} but `pattern: Type` is only a valid pattern if `pattern` is an Ident thus, we desugar to val x = (expr: Type) match { case pattern => (var_1, ..., var_N)} ... in this case (see def makePatDef) also, MaybeBoundType now fails on illegal patterns (to defend against similar regressions) --- test/files/run/virtpatmat_valdef.check | 1 + test/files/run/virtpatmat_valdef.scala | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 test/files/run/virtpatmat_valdef.check create mode 100644 test/files/run/virtpatmat_valdef.scala (limited to 'test/files') diff --git a/test/files/run/virtpatmat_valdef.check b/test/files/run/virtpatmat_valdef.check new file mode 100644 index 0000000000..1a45335bd2 --- /dev/null +++ b/test/files/run/virtpatmat_valdef.check @@ -0,0 +1 @@ +meh(true,null) diff --git a/test/files/run/virtpatmat_valdef.scala b/test/files/run/virtpatmat_valdef.scala new file mode 100644 index 0000000000..f1a9b46cdd --- /dev/null +++ b/test/files/run/virtpatmat_valdef.scala @@ -0,0 +1,6 @@ +object Test extends App { + // patterns in valdefs... + // TODO: irrefutability should indicate we don't actually need to test, just deconstruct + val (modified, result) : (Boolean, String) = (true, null) + println("meh"+ (modified, result)) +} \ No newline at end of file -- cgit v1.2.3