Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context receivers support #314

Closed
JavierSegoviaCordoba opened this issue Apr 22, 2022 · 5 comments
Closed

context receivers support #314

JavierSegoviaCordoba opened this issue Apr 22, 2022 · 5 comments

Comments

@JavierSegoviaCordoba
Copy link
Contributor

Currently, context add an unnecessary breakline:

context(ScanResult)

internal val ClassInfo.contextClasses: List<KClass<out Any>>
  get() =
    getClassesWithAnnotation(this.name).map { contextClassInfo ->
      contextClassInfo.loadClass().kotlin
    }

should be:

context(ScanResult)
internal val ClassInfo.contextClasses: List<KClass<out Any>>
  get() =
    getClassesWithAnnotation(this.name).map { contextClassInfo ->
      contextClassInfo.loadClass().kotlin
    }
@strulovich
Copy link
Contributor

It is likely we will only fix this when this comes out of preview. Happy to accept a PR once the dependencies sort themselves out (though it looks it might be future compatible from the fact Ktfmt doesn't crash on this)

@JavierSegoviaCordoba
Copy link
Contributor Author

JavierSegoviaCordoba commented Jun 14, 2022

I would like to know how it will be combined with annotations.

1

context(Persistence)
@Provider class Repo

2

context(Persistence)
@Provider
class Repo

3

@Provider
context(Persistence)
class Repo

The first one is which I like more but if there are a lot of annotations it will not look very good, so I think the third one is the best.

@JavierSegoviaCordoba
Copy link
Contributor Author

JavierSegoviaCordoba commented Aug 3, 2022

@strulovich I tried this myself but after updating Kotlin to 1.7.10 and 1.7.20 beta, I cannot get the context receivers in visitNamedFunction, I got an empty list even though the KotlinInput shows clearly they are there.

Not sure if I am missing something or if there is a way to try to get them tokenized without using the context receivers from PSI.

@JavierSegoviaCordoba
Copy link
Contributor Author

@strulovich as they are not going to be on 1.8.0, can this be prioritized a bit, please?

facebook-github-bot pushed a commit that referenced this issue Sep 13, 2023
Summary:
Resolves #397, #314 and #374.

Pull Request resolved: #400

Reviewed By: davidtorosyan

Differential Revision: D48169986

Pulled By: hick209

fbshipit-source-id: df4ffe4d939635b3db481ba478d52bffa4c78ec1
@hick209
Copy link
Contributor

hick209 commented Sep 18, 2023

Fixed by @bddckr (#400)

@hick209 hick209 closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants