raulraja
07/06/2019, 9:59 AMsyntheticResolver
.
Where users do something like:
func({
"fun <$typeArgs> $name($params): $returnType = $body" //find
}) { fn ->
"fun <$typeArgs> $name($params): $returnType = $body" //transform
}
In this case that would be the identity element for the ValueParameter
declaration quote. This is in a similar way the quasiquote style syntax that scala-meta uses and much easier for most use cases to develop compiler plugins in comparison with the compiler internals, descriptor and phases we have to deal today.
Say you had a use case to add logging to all functions named foo
that return Unit
. This will be the expression that satisfies that use case in a compiler plugin:
func({
"fun <$typeArgs> foo($params): Unit = $body" //find
}) { fn ->
"fun <$typeArgs> $name($params): $returnType {
println("inside foo: Unit")
return $body"
}
}
Imran/Malic
07/08/2019, 9:47 AMImran/Malic
07/08/2019, 10:10 AMHanno
07/10/2019, 10:04 AMraulraja
07/10/2019, 10:53 AMraulraja
07/10/2019, 10:54 AMraulraja
07/10/2019, 10:55 AM