From e6fa1ab1135d8504d7020c10962b7eb059499fd9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 8 Nov 2020 16:04:08 +0100 Subject: [PATCH] Fix #10062: Avoid bad case during typing --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 4 ++-- tests/run/i10062.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 tests/run/i10062.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index b90d72ab2996..fb7d69d0b86b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -600,8 +600,8 @@ trait Applications extends Compatibility { args match { case arg :: Nil if isVarArg(arg) => addTyped(arg, formal) - case Typed(Literal(Constant(null)), _) :: Nil => - addTyped(args.head, formal) + case (arg as Typed(Literal(Constant(null)), _)) :: Nil if ctx.isAfterTyper => + addTyped(arg, formal) case _ => val elemFormal = formal.widenExpr.argTypesLo.head val typedArgs = diff --git a/tests/run/i10062.scala b/tests/run/i10062.scala new file mode 100644 index 000000000000..900145852ae7 --- /dev/null +++ b/tests/run/i10062.scala @@ -0,0 +1,9 @@ +class X + +object X { + extension (x: List[X]) { def isNull = x.head == null } +} + +@main def Test = + assert(List(null: X).isNull) + assert(List((null: X)).isNull)