From 2c5719a4321cbfa5b069d3f79e553d79596272af Mon Sep 17 00:00:00 2001 From: Tom Grigg Date: Tue, 5 Jul 2022 11:35:28 -0700 Subject: [PATCH] Irrefutable for generators should not be filtering under `-source:future` Fixes #15579 --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/pos/i15579.scala | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15579.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index e8ecf1c88f8c..dd019e21b049 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2574,8 +2574,8 @@ object Parsers { atSpan(startOffset(pat), accept(LARROW)) { val checkMode = if casePat then GenCheckMode.FilterAlways - else if sourceVersion.isAtLeast(`3.2`) then GenCheckMode.CheckAndFilter else if sourceVersion.isAtLeast(`future`) then GenCheckMode.Check + else if sourceVersion.isAtLeast(`3.2`) then GenCheckMode.CheckAndFilter else GenCheckMode.FilterNow // filter on source version < 3.2, for backward compat GenFrom(pat, subExpr(), checkMode) } diff --git a/tests/pos/i15579.scala b/tests/pos/i15579.scala new file mode 100644 index 000000000000..64b67cf3c069 --- /dev/null +++ b/tests/pos/i15579.scala @@ -0,0 +1,10 @@ +// scalac: -source:future + +trait Foo[A]: + def map[B](f: A => B): Foo[B] = ??? + +def baz: Foo[(Int, String)] = ??? + +@main def main = + for (x, y) <- baz + yield ()