@@ -216,7 +216,7 @@ type `1`.
216216``` scala
217217inline def zero () <: Int = 0
218218
219- final val one : 1 = zero() + 1
219+ val one : 1 = zero() + 1
220220```
221221
222222## Inline Conditionals
@@ -285,7 +285,7 @@ inline def toInt(n: Nat) <: Int = inline n match {
285285 case Succ (n1) => toInt(n1) + 1
286286}
287287
288- final val natTwo = toInt(Succ (Succ (Zero )))
288+ val natTwo = toInt(Succ (Succ (Zero )))
289289val intTwo : 2 = natTwo
290290```
291291
@@ -309,7 +309,7 @@ inline def toIntC[N] <: Int =
309309 case _ : S [n1] => 1 + toIntC[n1]
310310 }
311311
312- final val ctwo = toIntC[2 ]
312+ val ctwo = toIntC[2 ]
313313```
314314
315315` constValueOpt ` is the same as ` constValue ` , however returning an ` Option[T] `
@@ -338,6 +338,8 @@ called. But the function can in fact never be called, since it is declared
338338Using ` erasedValue ` , we can then define ` defaultValue ` as follows:
339339
340340``` scala
341+ import scala .compiletime .erasedValue
342+
341343inline def defaultValue [T ] = inline erasedValue[T ] match {
342344 case _ : Byte => Some (0 : Byte )
343345 case _ : Char => Some (0 : Char )
@@ -372,7 +374,7 @@ inline def toIntT[N <: Nat] <: Int = inline scala.compiletime.erasedValue[N] mat
372374 case _ : Succ [n] => toIntT[n] + 1
373375}
374376
375- final val two = toIntT[Succ [Succ [Zero .type ]]]
377+ val two = toIntT[Succ [Succ [Zero .type ]]]
376378```
377379
378380` erasedValue ` is an ` erased ` method so it cannot be used and has no runtime
@@ -392,6 +394,8 @@ If an inline expansion results in a call `error(msgStr)` the compiler
392394produces an error message containing the given ` msgStr ` .
393395
394396``` scala
397+ import scala .compiletime .error
398+
395399inline def fail () = {
396400 error(" failed for a reason" )
397401}
404408inline def fail (p1 : => Any ) = {
405409 error(code " failed on: $p1" )
406410}
407- fail(indentity (" foo" )) // error: failed on: indentity ("foo")
411+ fail(identity (" foo" )) // error: failed on: identity ("foo")
408412```
409413
410414## Summoning Implicits Selectively
0 commit comments