-
Notifications
You must be signed in to change notification settings - Fork 9
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
ContributeSubComponent: Support returning Super Type #83
Changes from 4 commits
9ffba8e
d232a1d
5d80583
c0cdd9e
e3b7546
f7d683d
4d4eaa8
6dfd96d
3e696e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,9 +405,18 @@ internal class KspContributesSubcomponentHandlerSymbolProcessor( | |
} else { | ||
function.asMemberOf(implementingType).returnTypeOrNull() | ||
} | ||
returnTypeToCheck | ||
?.resolveKSClassDeclaration() | ||
?.toClassName() == contributionClassName | ||
|
||
val returnType = returnTypeToCheck?.resolveKSClassDeclaration() | ||
if (returnType?.toClassName() == contributionClassName) { | ||
return@filter true | ||
} | ||
|
||
val isReturningSuperType = returnType != null && contribution.clazz.superTypes.any { | ||
it.resolve().resolveKSClassDeclaration() == returnType | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a Resolver API for checking if one type is a subtype of another. I don't remember the name exactly but we should use that one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found So something like this: returnTypeToCheck.isAssignableFrom(contribution.clazz.asType(emptyList())) |
||
if (isReturningSuperType) return@filter true | ||
|
||
false | ||
} | ||
.toList() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove these since I'm removing the K1 support anyway