diff options
Diffstat (limited to 'tests/pos')
-rw-r--r-- | tests/pos/extractors.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/pos/extractors.scala b/tests/pos/extractors.scala new file mode 100644 index 000000000..8e5b0e9d2 --- /dev/null +++ b/tests/pos/extractors.scala @@ -0,0 +1,32 @@ +object test { + + class Tree + class Apply(val fun: Tree, val args: List[Tree]) extends Tree + + trait DeconstructorCommon[T >: Null <: AnyRef] { + var field: T = null + def get: this.type = this + def isEmpty: Boolean = field eq null + def isDefined = !isEmpty + def unapply(s: T): this.type ={ + field = s + this + } + } + + trait ApplyDeconstructor extends DeconstructorCommon[Apply] { + def _1: Tree + def _2: List[Tree] + } + + object Apply extends ApplyDeconstructor { + def _1: Tree = field.fun + def _2: List[Tree] = field.args + } + + def assocsFromApply(tree: Tree) = { + tree match { + case Apply(fun, args) => ??? + } + } +} |