aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/CtxLazy.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/transform/CtxLazy.scala')
-rw-r--r--src/dotty/tools/dotc/transform/CtxLazy.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/transform/CtxLazy.scala b/src/dotty/tools/dotc/transform/CtxLazy.scala
new file mode 100644
index 000000000..c0bac4e11
--- /dev/null
+++ b/src/dotty/tools/dotc/transform/CtxLazy.scala
@@ -0,0 +1,12 @@
+package dotty.tools.dotc
+package util
+import core.Contexts.Context
+
+class CtxLazy[T](expr: Context => T) {
+ private var myValue: T = _
+ private var forced = false
+ def apply()(implicit ctx: Context): T = {
+ if (!forced) myValue = expr(ctx)
+ myValue
+ }
+} \ No newline at end of file