Hey, just noticed the message in feed channel, qui...
# pattern-matching
s
Hey, just noticed the message in feed channel, quite cool to see people interested in implementing lang features as a plugin (especially using meta :D) I have played around with the PR for an hour or so and managed to make it working for examples you have. I am still assuming a lot in that code, and also not sure how I can merge it, so will just leave a diff with your upstream here 🙂 It would be great if you could check that it works not only on my machine.
😍 1
@mattmoore tagging you just in case :)
m
This is great! I will pull this down today and try it out. You may have actually helped us get through analysis, it appears 🙂
s
It actually generates correct IR, accidentally
😄
m
Nice! That would save some time then having to do IR transforms.
s
essentially, you've been missing a source for this identifier, like where it got assigned from so I traced it to
person.{nth-property}
💯 1
I am actually curious how we can make it work with capturing params
m
Me too! With this in place I’ll start taking a look at that today. By the way, feel free to open a PR against the pattern-matching branch on Arrow Meta repo.
s
Sure 🙂 Also curious, why you have added
case
method?
m
Originally, to follow similar to Scala, as well as to have an easy way to find and restrict pattern matching behavior to only what's inside case, given that
_
is a reserved Kotlin keyword. However, if we can find a good way to restrict the meaning of
_
without
case
, then we can get rid of that. I think it's already something I've gotten sufficiently working by checking only for
_
where the type is
null
during analysis phase:
Copy code
private val BindingTrace.wildcardTypeInfoEntries: List<MutableMap.MutableEntry<KtExpression, KotlinTypeInfo>>
  get() = bindingContext.getSliceContents(BindingContext.EXPRESSION_TYPE_INFO).entries
    .filter { it.value.type == null && it.key.text == "_" }
So
case
can likely go away now.
s
Ah, makes sense, thanks
👍🏻 1
m
@shikasd I was able to run your patch locally and can confirm it works!
s
Amazing, thanks :)