Skip to content

Commit 407f9b4

Browse files
authored
Merge pull request scala#7680 from dotty-staging/fix-#7675
Fix scala#7675: Handle case of lazy patterns with no variables
2 parents d217690 + c9c4fc1 commit 407f9b4

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ object desugar {
10861086
if (tupleOptimizable) rhs
10871087
else Match(makeSelector(rhs, MatchCheck.IrrefutablePatDef), caseDef :: Nil)
10881088
vars match {
1089-
case Nil =>
1089+
case Nil if !mods.is(Lazy) =>
10901090
matchExpr
10911091
case (named, tpt) :: Nil =>
10921092
derivedValDef(original, named, tpt, matchExpr, mods)

tests/run/i7675.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello, World!

tests/run/i7675.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Test extends App {
2+
lazy val _ = ??? // throws an exception
3+
println("Hello, World!")
4+
}

0 commit comments

Comments
 (0)