Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/cgp-macro-lib/src/cgp_impl/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ pub fn transform_impl_trait(
let mut out_impl: ItemImpl = parse2(raw_out_impl)?;
out_impl.self_ty = Box::new(provider_type.clone());

let mut provider_trait_path: SimpleType = consumer_trait_path.clone();
let mut provider_trait_path: SimpleType = parse2(replace_self_type(
consumer_trait_path.to_token_stream(),
context_type.to_token_stream(),
&local_assoc_types,
))?;

match &mut provider_trait_path.generics {
Some(generics) => {
Expand Down
14 changes: 14 additions & 0 deletions crates/cgp-tests/tests/component_tests/abstract_types/generics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use cgp::prelude::*;

#[cgp_component(FooProvider)]
pub trait Foo<T> {
fn foo(&self, value: &T);
}

// Test that the `Error` parameter in `FooProvider<Error>`
// is desugared correctly into `Context::Error` and not `Self::Error`
#[cgp_impl(new FooError)]
#[use_type(HasErrorType::Error)]
impl FooProvider<Error> {
fn foo(&self, _value: &Error) {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod basic;
pub mod extend;
pub mod foreign;
pub mod generics;
pub mod self_referential;
Loading