what's happening with the `quoteOutputMatches`? Wh...
# arrow-meta
a
what's happening with the
quoteOutputMatches
? Why are there repetitive code in the source strings between both the code snippet and whatever is in
quoteOutputMatches(...)
? i.e. HigherTestPlugins.kt
i
quoteOutputMatches
is agnostic to what we think of the QuoteSystem.
Input
Output
. Thus the Test does exactly this. It checks what the user writes and test the output of compilation. You can see it here https://github.com/arrow-kt/arrow-meta/blob/b1ed3bdcff0fe2056fe9f58a233c6a9533e2cd27/testing-plugin/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt#L83
a
the output of the compilation?
I'm unclear what it is
for example, from the HigherTypes test
Copy code
assertThis(CompilerTest(
      config = { metaDependencies },
      code = {
        """
        | import arrow.higherkind
        | 
        | //metadebug
        | 
        | @higherkind
        | class Id2<out A>(val value: A)
        | 
        | val x: Id2Of<Int> = Id2(1)
        | 
        """.source
      },
      assert = {
        allOf(quoteOutputMatches(
          """
          | import arrow.higherkind
          | 
          | //meta: <date>
          | 
          | @arrow.synthetic class ForId2 private constructor() { companion object }
          | @arrow.synthetic typealias Id2Of<A> = arrow.Kind<ForId2, A>
          | @arrow.synthetic typealias Id2KindedJ<A> = arrow.HkJ<ForId2, A>
          | @arrow.synthetic fun <A> Id2Of<A>.fix(): Id2<A> =
          |   this as Id2<A>
          | @arrow.synthetic @higherkind /* empty? */class Id2 <out A> public constructor (val value: A) : Id2Of<A> {}
          | 
          | val x: Id2Of<Int> = Id2(1)
          | 
          """.source))
What is this compilation result with all the
@arrow.synthetic
stuff?
Is this meant to portrait how the compiler will interpret the code with the plugin?
i
Let me rephrase. One of the core idea behind the QuoteSystem is to intercept user code and passing new user code to the compilation step. Similar to a function
f:(Code) -> Code
Yes the annotation
@arrow.synthetic
is part of the implementation details within the
HigherkindedPlugin
.
And as you see in the code base there is a set of functions we can use to intercept different parts of code, for instance Functions with
func
or type Aliases with
typeAlias
. These are just instances, plugin developers can always extend it to other areas, too. Interestingly enough, this gives you the power to drop code generation frameworks like kapt entirely with the advantage to have the newly constructed code at compile time. The Ide plugin also supports those synthetic members to be in scope, so your not getting redlines.
💯 1
r
@arrow.synthetic is how the PakacgeFragmentProvider in IDEA gets the synth descriptors the IDE needs extracting those annotated like that from the class files
quoteOutputMatches
is an assert where you can assert the output you expect the quote system to generate in text form.
💯 1
since the quote system is mostly used for source code generation
💯 1
a
^^^ that's what I was looking for
r
.synthetic
in ElementScope annotates anything you generate in the quote system as
@arrow.synthetic
and that makes it automatically discoverable by the IDE when you compile the project and Arrow Meta can extract the synth descriptors from the class files disregarding anything that is not annotated by
@arrow.synthetic
a
The expected output then, is the target code generated
r
right
👍 1
before it goes into typechecking
so whatever the quotes produce which is just source code
a
awesome, thanks!
👍 1