Skip to content

Commit 0882d10

Browse files
committed
Restore error checking
1 parent ab68632 commit 0882d10

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,10 @@ trait Applications extends Compatibility {
14451445
})
14461446
unapplyPatterns += typed(term, argTypes.head)
14471447
argTypes = argTypes.tail
1448+
} else {
1449+
// Check for positional arguments
1450+
if (argTypes != Nil || bunchedArgs != Nil)
1451+
report.error(UnapplyInvalidNumberOfArguments(qual, argTypes), tree.srcPos)
14481452
}
14491453

14501454
val result = assignType(cpy.UnApply(tree)(unapplyFn, unapplyImplicits(unapplyApp), unapplyPatterns.result), ownType)

compiler/test/dotty/tools/dotc/NamedPatternMatching.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class NamedPatternMatching {
3434
implicit val testGroup: TestGroup = TestGroup("compileNeg")
3535
aggregateTests(
3636
compileFile("tests/neg/negNamedPatternMatching.scala", defaultOptions),
37+
compileFile("tests/neg/bad-unapplies.scala", defaultOptions),
3738
).checkExpectedErrors()
3839
}
3940

0 commit comments

Comments
 (0)