diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-04 14:48:23 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-04 14:48:23 -0700 |
commit | 7360d060f8da122cf233f6b761cc49044574d2fc (patch) | |
tree | 985710c39c1bc8fb05a0701899de6c5e426a8e1d /core/src/main/scala/forge/util/LocalDef.scala | |
parent | bc6eb79f74a30aef2eb874eb7ba3c443c49e7554 (diff) | |
download | mill-7360d060f8da122cf233f6b761cc49044574d2fc.tar.gz mill-7360d060f8da122cf233f6b761cc49044574d2fc.tar.bz2 mill-7360d060f8da122cf233f6b761cc49044574d2fc.zip |
Collapse `LocalDef` into `T{...}` macro, make it more flexible so it only caches `def`s (and complains about `val`s) if it's defined top-level in a class/trait/object, for easy overriding.
If it's in some helper function somewhere, overriding doesn't matter, and it's up to the user to figure out how to construct a target graph without redundancy
Diffstat (limited to 'core/src/main/scala/forge/util/LocalDef.scala')
-rw-r--r-- | core/src/main/scala/forge/util/LocalDef.scala | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/core/src/main/scala/forge/util/LocalDef.scala b/core/src/main/scala/forge/util/LocalDef.scala deleted file mode 100644 index 2a58bbd2..00000000 --- a/core/src/main/scala/forge/util/LocalDef.scala +++ /dev/null @@ -1,28 +0,0 @@ -package forge.util - -import scala.reflect.macros.blackbox -import language.experimental.macros -class LocalDef -object LocalDef { - implicit def default: LocalDef = macro enclosing - def enclosing(c: blackbox.Context): c.Expr[LocalDef] = { - - import c.universe._ - val current = c.internal.enclosingOwner - - if ( - !current.isMethod || - // We can't do this right now because it causes recursive method errors - // current.asMethod.paramLists.nonEmpty || - !(current.owner.isClass || current.owner.isModuleClass) - ) { - c.abort( - c.enclosingPosition, - "T{} can only be used directly within a zero-arg method defined in a class body" - ) - }else{ - - c.Expr[LocalDef](q"""new forge.util.LocalDef()""") - } - } -} |