Skip to content

Commit c4d2be9

Browse files
committed
Fix handling of null in qualifiers
1 parent d52aff0 commit c4d2be9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

compiler/src/dotty/tools/dotc/qualified_types/ENode.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ object ENode:
461461
case tpd.Literal(_) | tpd.Ident(_) | tpd.This(_)
462462
if tree.tpe.isInstanceOf[SingletonType] && tpd.isIdempotentExpr(tree) =>
463463
Some(Atom(substParamRefs(tree.tpe, paramSyms, paramTps).asInstanceOf[SingletonType]))
464+
case tpd.Literal(Constant(null)) => // null does not have a SingletonType
465+
Some(Atom(ConstantType(Constant(null))))
464466
case tpd.Select(tpd.New(_), nme.CONSTRUCTOR) =>
465467
constructorNode(tree.symbol)
466468
case tree: tpd.Select if isCaseClassApply(tree.symbol) =>

tests/pos-custom-args/qualified-types/class_constraints.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ class Multi(x: Int with x > 0)(y: String with y.length > 2, z: Double with z >=
44

55
case class MultiCase(x: Int with x > 0)(val y: String with y.length > 2, val z: Double with z >= 0.0)
66

7+
class TParam[T](x: T with x != null)
8+
79
@main def Test = ()

0 commit comments

Comments
 (0)