File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class InlineVals extends MiniPhase:
4242 if tp.derivesFrom(defn.StringClass ) || defn.ScalaValueClasses ().exists(tp.derivesFrom(_)) then
4343 val pos = if tpt.span.isZeroExtent then rhs.srcPos else tpt.srcPos
4444 report.error(em " inline value must have a literal constant type " , pos)
45+ else if tp.derivesFrom(defn.NullClass ) then
46+ report.error(em " `inline val` with `null` is no supported. \n\n To inline a `null` consider using `inline def` " , rhs)
4547 else
4648 report.error(em " inline value must contain a literal constant value. \n\n To inline more complex types consider using `inline def` " , rhs)
4749 }
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i12177.scala:2:17 ----------------------------------------------------------------------------------
2+ 2 | inline val v = null // error
3+ | ^^^^
4+ | `inline val` with `null` is no supported.
5+ |
6+ | To inline a `null` consider using `inline def`
Original file line number Diff line number Diff line change 1+ object Test1 {
2+ inline val v = null // error
3+ inline def d = null
4+ }
You can’t perform that action at this time.
0 commit comments