Skip to content

Commit

Permalink
Removes wrong test case, and applies review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrubal committed Jan 30, 2023
1 parent 4154540 commit 5bcdcad
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 56 deletions.
28 changes: 2 additions & 26 deletions sway-core/src/semantic_analysis/namespace/trait_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ impl TraitMap {
type_implementing_for: engines.help_out(type_id).to_string(),
second_impl_span: impl_span.clone(),
});
} else if types_are_subset {
} else if types_are_subset && (traits_are_subset || is_impl_self) {
for (name, decl_id) in trait_methods.iter() {
if let Some(map_trait_method_decl_id) = map_trait_methods.get(name) {
if map_trait_methods.get(name).is_some() {
let method = check!(
CompileResult::from(
decl_engine.get_function(decl_id.clone(), impl_span)
Expand All @@ -201,30 +201,6 @@ impl TraitMap {
warnings,
errors
);
let map_trait_method = check!(
CompileResult::from(
decl_engine
.get_function(map_trait_method_decl_id.clone(), impl_span)
),
return err(warnings, errors),
warnings,
errors
);
if !traits_are_subset
&& !is_impl_self
&& (method.parameters.len() != map_trait_method.parameters.len()
|| method
.parameters
.iter()
.zip(map_trait_method.parameters.iter())
.any(|(p1, p2)| {
!are_equal_minus_dynamic_types(
engines, p1.type_id, p2.type_id,
)
}))
{
continue;
}
errors.push(CompileError::DuplicateMethodsDefinedForType {
func_name: method.name.to_string(),
type_implementing_for: engines.help_out(type_id).to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,6 @@ impl Data<u8> {
}
}

pub struct A {
a: u64,
}

pub struct B {
b: u64,
}

pub struct C {
c: u64,
}

pub trait Convert<T> {
fn convert(t: u64);
}

impl Convert<B> for A {
fn convert(t: u64) {
}
}

impl Convert<C> for A {
// duplicate definition
fn convert(t: u64) {
}
}

fn main() {

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ category = "fail"

# check: $()fn my_add(self, other: Self) -> Self {
# check: $()Duplicate definitions for the method "my_add" for type "Data<u32>".

# check: $()fn convert(t: u64) {
# check: $()Duplicate definitions for the method "convert" for type "A".

0 comments on commit 5bcdcad

Please sign in to comment.