Skip to content

Commit 8743454

Browse files
authored
Merge pull request #5660 from eklavya/issue-5640
Fixes #5640 Typer crash on 0 arity tuple
2 parents 1d58b64 + 2690241 commit 8743454

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,9 @@ object desugar {
920920
assert(arity <= Definitions.MaxTupleArity)
921921
def tupleTypeRef = defn.TupleType(arity)
922922
if (arity == 1) ts.head
923+
else if (arity == 0)
924+
if (ctx.mode is Mode.Type) TypeTree(defn.UnitType) else unitLiteral
923925
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
924-
else if (arity == 0) unitLiteral
925926
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
926927
}
927928

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)