File tree 3 files changed +12
-0
lines changed
compiler/src/dotty/tools/dotc/transform 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:
42
42
if tp.derivesFrom(defn.StringClass ) || defn.ScalaValueClasses ().exists(tp.derivesFrom(_)) then
43
43
val pos = if tpt.span.isZeroExtent then rhs.srcPos else tpt.srcPos
44
44
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)
45
47
else
46
48
report.error(em " inline value must contain a literal constant value. \n\n To inline more complex types consider using `inline def` " , rhs)
47
49
}
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