Skip to content

Commit 3b2bcee

Browse files
Merge pull request #10234 from dotty-staging/fix-#10062
Fix #10062: Avoid bad case during typing
2 parents 3938388 + e6fa1ab commit 3b2bcee

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ trait Applications extends Compatibility {
600600
args match {
601601
case arg :: Nil if isVarArg(arg) =>
602602
addTyped(arg, formal)
603-
case Typed(Literal(Constant(null)), _) :: Nil =>
604-
addTyped(args.head, formal)
603+
case (arg as Typed(Literal(Constant(null)), _)) :: Nil if ctx.isAfterTyper =>
604+
addTyped(arg, formal)
605605
case _ =>
606606
val elemFormal = formal.widenExpr.argTypesLo.head
607607
val typedArgs =

tests/run/i10062.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class X
2+
3+
object X {
4+
extension (x: List[X]) { def isNull = x.head == null }
5+
}
6+
7+
@main def Test =
8+
assert(List(null: X).isNull)
9+
assert(List((null: X)).isNull)

0 commit comments

Comments
 (0)