From 3c0a83d19f56061bc9f621372cc7a5245d1204f6 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 12 Dec 2023 14:13:26 -0800 Subject: 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 --- apex/classpath_element_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apex/classpath_element_test.go') diff --git a/apex/classpath_element_test.go b/apex/classpath_element_test.go index 9142eed99..1ce60ced9 100644 --- a/apex/classpath_element_test.go +++ b/apex/classpath_element_test.go @@ -33,11 +33,11 @@ type testClasspathElementContext struct { errs []error } -func (t *testClasspathElementContext) OtherModuleHasProvider(module blueprint.Module, provider blueprint.ProviderKey) bool { +func (t *testClasspathElementContext) OtherModuleHasProvider(module blueprint.Module, provider blueprint.AnyProviderKey) bool { return t.testContext.ModuleHasProvider(module, provider) } -func (t *testClasspathElementContext) OtherModuleProvider(module blueprint.Module, provider blueprint.ProviderKey) interface{} { +func (t *testClasspathElementContext) OtherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) interface{} { return t.testContext.ModuleProvider(module, provider) } -- cgit v1.2.3-59-g8ed1b