File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
src/library/scala/annotation Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,29 @@ package scala.annotation
75
75
* (O: C).f() // elided if compiled with `-Xelide-below 1`
76
76
* }
77
77
* }}}
78
+ *
79
+ * Note for Scala 3 users:
80
+ * If you're using Scala 3, the annotation exists since Scala 3 uses the Scala 2
81
+ * standard library, but it's unsupported by the Scala 3 compiler. Instead, to
82
+ * achieve the same result you'd want to utilize the `inline if` feature to
83
+ * introduce behavior that makes a method de facto elided at compile-time.
84
+ * {{{
85
+ * type LogLevel = Int
86
+ *
87
+ * object LogLevel:
88
+ * inline val Info = 0
89
+ * inline val Warn = 1
90
+ * inline val Debug = 2
91
+ *
92
+ * inline val appLogLevel = LogLevel.Warn
93
+ *
94
+ * inline def log(msg: String, inline level: LogLevel): Unit =
95
+ * inline if (level <= appLogLevel) then println(msg)
96
+ *
97
+ * log("Warn log", LogLevel.Warn)
98
+ *
99
+ * log("Debug log", LogLevel. Debug)
100
+ * }}}
78
101
*/
79
102
final class elidable (final val level : Int ) extends scala.annotation.ConstantAnnotation
80
103
You can’t perform that action at this time.
0 commit comments