Extract DepIsInSameApex and RequiredSdks interfaces

The DepIsInSameApex() and RequiredSdks() methods were defined in a few
places to avoid having to depend on the whole ApexModule/SdkAware
interfaces directly. However, that has a couple of issues:
1) It duplicates functionality making it difficult to change, changes
   to the definitions outside the main interfaces do not cause compile
   time failures, instead they result in a runtime change in behavior
   which can be difficult to debug.
2) IDE navigation (specifically in Intellij) does not detect that the
   duplicate definitions can resolve to the definitions in the main
   interface.

This change extracts the methods into their own interfaces and reuses
those interfaces instead of duplicating the methods to fix both of
these issues.

Bug: 152878661
Bug: 153306490
Test: m nothing
Merged-In: I0cfdf342a14eb0bfb82b1bd17e0633d81c7facfb
Change-Id: I0cfdf342a14eb0bfb82b1bd17e0633d81c7facfb
This commit is contained in:
Paul Duffin
2020-03-30 15:33:32 +01:00
parent 3c7c34769d
commit 03e7d0ca9c
4 changed files with 27 additions and 10 deletions

View File

@@ -434,8 +434,8 @@ func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) {
// Step 6: ensure that the dependencies from outside of the APEX are all from the required SDKs
func sdkRequirementsMutator(mctx android.TopDownMutatorContext) {
if m, ok := mctx.Module().(interface {
DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool
RequiredSdks() android.SdkRefs
android.DepIsInSameApex
android.RequiredSdks
}); ok {
requiredSdks := m.RequiredSdks()
if len(requiredSdks) == 0 {