Skip to content

Commit ceddf52

Browse files
committed
cleaner workaround for #7882
1 parent 4a1c9f2 commit ceddf52

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

library/src/scala/runtime/Scala3RunTime.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ object Scala3RunTime:
1515
* Extracted to minimize the bytecode size at call site.
1616
*/
1717
def nn[T](x: T | Null): x.type & T =
18-
val isNull = x == null
19-
if (isNull) throw new NullPointerException("tried to cast away nullability, but value is null")
20-
else x.asInstanceOf[x.type & T]
18+
if (x == null) throw new NullPointerException("tried to cast away nullability, but value is null")
19+
else x
2120

2221
end Scala3RunTime

0 commit comments

Comments
 (0)