Skip to content

Commit 871a87e

Browse files
committed
Fix #5640 Typer crash on 0 arity tuple
1 parent 7b9ffbb commit 871a87e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-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
@@ -920,8 +920,8 @@ object desugar {
920920
assert(arity <= Definitions.MaxTupleArity)
921921
def tupleTypeRef = defn.TupleType(arity)
922922
if (arity == 1) ts.head
923-
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
924923
else if (arity == 0) unitLiteral
924+
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
925925
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
926926
}
927927

tests/neg/i5640.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object test {
2+
val foo = (()) => () // error: not a legal formal parameter
3+
}

0 commit comments

Comments
 (0)