vampire methods

26
Vampire Methods ScalaSyd

Upload: specs2

Post on 07-Aug-2015

60 views

Category:

Technology


1 download

TRANSCRIPT

Vampire Methods

ScalaSyd

Can you do this?

@xeno_by jumps in

Kittens!

Kittens!

Generate a loca

l class!

Local CatMatcher

Paradise plugin

Just for q

uasi-quotes

Local CatMatcher

Batman

Local CatMatcher

http://stackoverflow.com/questions/18480707/method-cannot-be-accessed-in-macro-generated-class

Don’t forg

et the {}!

Real incremental recompilation

Let’s dive

Grab the Cat

TypeTag not acc

essible in

a macro

!

Wash the Cat

Inception matcher

Builder pattern

Matcher methods

// CatMatcher

Inception matcher

Cat matcher

Internal state

Inception matcher

new constraint =>new matcher function

name/age/kitten methods

list of c.Expr[_]

Mirror, mirror

structu

ral type =

>

reflection :-(

// age

// matchA[Cat].age(6)

// Int

Yo, I heard you like macros

No stru

ctural ty

pe!

Yo, I heard you like macros

Annotation code

// @fieldMatcherBody(expected => cat.age must_== expected)

// val expected = 6

// cat.age must_== expected

Yo, I heard you like macros

extract parameter/body

Transformers

// 6

// `prefix` represents an equivalent of // `this` for normal instance methods

// body:// CatMatcher.this.addMatcher((_:Cat).age must_== arg)

Transformers

http://stackoverflow.com/questions/18523871/use-this-in-a-generated-macro-method

Transformers -Yrangepos

Can you do this?

YES !!!

Thank you!

If you followed that far…