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

Add helper for equivlent of Types.asMemeberOf #49

Closed
evant opened this issue Jun 12, 2020 · 3 comments · Fixed by #110
Closed

Add helper for equivlent of Types.asMemeberOf #49

evant opened this issue Jun 12, 2020 · 3 comments · Fixed by #110
Labels
P1 major features or blocking bugs
Milestone

Comments

@evant
Copy link
Contributor

evant commented Jun 12, 2020

When writing an annotation processor you can use Types.asMemeberOf() to resolve the concrete type of a method based on the enclosing class. Ex if you had:

interface GenericInterface<T> {
  bar(): T
}

abstract class Foo : GenericInterface<String> {
}

you could get that bar() in the context of Foo returns String.

@neetopia
Copy link
Collaborator

neetopia commented Jun 12, 2020

We have this in our reference.md for asMemeberOf()
asMemberOf | ksClassDeclaration.typeArguments + ksClassDeclaration.asType

does this serve your purpose? It looks what you need is a type substitution for the type parameter of bar().

@ting-yuan
Copy link
Collaborator

ting-yuan commented Jun 19, 2020

Besides using the type directly, I guess Types.asMemberOf() is also useful on deducing the type arguments. This can be expensive potentially as it needs to resolve all the way up to the supertype that contains the member in question.

Let's make this P3 (nice to have) for now.

@ting-yuan ting-yuan transferred this issue from android/kotlin Sep 25, 2020
@ting-yuan ting-yuan added the P1 major features or blocking bugs label Oct 3, 2020
@ting-yuan ting-yuan added this to the 2020Q4 milestone Oct 3, 2020
@yigit
Copy link
Collaborator

yigit commented Oct 5, 2020

FYI I started working on this: https://github.com/yigit/ksp/tree/as-member-of based on the version in Room.
No promises on the timeline though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 major features or blocking bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants