Support multiple level inheritance for lib and app modules in case of KSP usage #5344
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In Datadog we have instrumentation for Glide by the means of creating
DatadogGlideModule
which inherits fromAppGlideModule
. Customers can extendDatadogGlideModule
instead ofAppGlideModule
and get their Glide calls instrumented with Datadog.This worked fine for KAPT, but doesn't work for KSP, because in case of KSP usage compilation with some class which inherits
DatadogGlideModule
instead ofAppGlideModule
directly gives the same error as in #5328.This happens because
supertypes
call here checks only types at declaration site and doesn't go through the whole inheritance chain up.This PR fixes that issue by traversing the whole inheritance chain, so that functionality is aligned with KAPT compiler (which permits such inheritance chains).
NB: Since we have to traverse the whole inheritance chain and
AppGlideModule
extends actuallyLibraryGlideModule
, it may be tricky to not register app module as library module as well, but since this PR is usingfirst
item in the supertype match, app module will be still registered as app module and not as both.