summaryrefslogtreecommitdiff
path: root/java/classpath_element.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2023-12-12 14:13:26 -0800
committer Colin Cross <ccross@android.com> 2023-12-14 16:12:20 -0800
commit3c0a83d19f56061bc9f621372cc7a5245d1204f6 (patch)
tree4aad30e3db38c504452ba34eb531565f0b71b7f0 /java/classpath_element.go
parente8eeec913f4c8cd00cfa30afc064b229fcdf0a51 (diff)
Use generics for providers API
Using generics for the providers API allows a type to be associated with a ProviderKey, resulting in a type-safe API without that doesn't require runtime type assertions by every caller. Unfortunately, Go does not allow generic types in methods, only in functions [1]. This prevents a type-safe API on ModuleContext, and requires moving the API to be functions that take a ModuleContext as a parameter. This CL creates the new API, but doesn't convert all of the callers. [1] https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#no-parameterized-methods) Bug: 316410648 Test: builds Change-Id: I3e30d68b966b730efd968166a38a25cc144bd6de
Diffstat (limited to 'java/classpath_element.go')
-rw-r--r--java/classpath_element.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/java/classpath_element.go b/java/classpath_element.go
index 496291678..af99fb4fb 100644
--- a/java/classpath_element.go
+++ b/java/classpath_element.go
@@ -72,8 +72,8 @@ var _ ClasspathElement = (*ClasspathLibraryElement)(nil)
// ClasspathElementContext defines the context methods needed by CreateClasspathElements
type ClasspathElementContext interface {
- OtherModuleHasProvider(m blueprint.Module, provider blueprint.ProviderKey) bool
- OtherModuleProvider(m blueprint.Module, provider blueprint.ProviderKey) interface{}
+ OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool
+ OtherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) interface{}
ModuleErrorf(fmt string, args ...interface{})
}