raulraja
06/25/2019, 11:59 PM@with
to enhance the scope resolution of that function so it takes in account the Semigroup<A>
type to resolve combine
without the need to wrap the body in with (S) { a.combine(b) }
.
What part of the compiler do I need to look into to avoid the unresolved reference: combine
?
In the actual Keep impl this happens in the BodyResolver
but not sure how to get to that point in a compiler plugin. Any help or pointers in the right direction is appreciated.dmitriy.novozhilov
06/26/2019, 7:03 AMcontext.scope
before entering to resolution and inference to new scope with new ownerDescriptor
that should be some descriptor with receiver that you want (see CallResolver.java:564
)dmitriy.novozhilov
06/26/2019, 7:07 AMobject Contained {
fun <A> add(S: Semigroup<A>, a: A, b: A): A {
a.combine(b) // 1
with(S) {
a.combine(b) // 2
}
}
}
For that code for call 1 scope owner is fun add
, for call 2 -- fun Semigroup<A>.<anonymous>()
. So, for call PsiCallResolver creates ScopeTower
(PSICallResolver.kt:91
) that looks for functions in appropriate member scopes.dmitriy.novozhilov
06/26/2019, 7:09 AMraulraja
06/26/2019, 12:02 PM