From 38813bf5a3ac98ac89dc62104a4291793ed68a30 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 31 Dec 2017 11:38:27 -0800 Subject: [PATCH] Allow Nothing sequence argument There's nothing wrong with `List(??? : _*)` pun intended. --- .../scala/tools/nsc/typechecker/PatternTypers.scala | 10 ++++++---- test/files/pos/t8343.scala | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 test/files/pos/t8343.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala index 3ff22a4117d8..100480a6d29f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala @@ -133,8 +133,9 @@ trait PatternTypers { val Typed(expr, tpt) = tree val exprTyped = typed(expr, mode) val baseClass = exprTyped.tpe.typeSymbol match { - case ArrayClass => ArrayClass - case _ => SeqClass + case ArrayClass => ArrayClass + case NothingClass => NothingClass + case _ => SeqClass } val starType = baseClass match { case ArrayClass if isPrimitiveValueType(pt) || !isFullyDefined(pt) => arrayType(pt) @@ -143,8 +144,9 @@ trait PatternTypers { } val exprAdapted = adapt(exprTyped, mode, starType) exprAdapted.tpe baseType baseClass match { - case TypeRef(_, _, elemtp :: Nil) => treeCopy.Typed(tree, exprAdapted, tpt setType elemtp) setType elemtp - case _ => setError(tree) + case TypeRef(_, _, elemtp :: Nil) => treeCopy.Typed(tree, exprAdapted, tpt setType elemtp) setType elemtp + case _ if baseClass eq NothingClass => exprAdapted + case _ => setError(tree) } } diff --git a/test/files/pos/t8343.scala b/test/files/pos/t8343.scala new file mode 100644 index 000000000000..f27d15ff5a69 --- /dev/null +++ b/test/files/pos/t8343.scala @@ -0,0 +1,4 @@ + +trait T { + def f = List[Int](??? : _*) +}