Error calling supertrait method via trait reference #4295

Closed
jdm opened this Issue Dec 27, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@jdm
Contributor

jdm commented Dec 27, 2012

trait A {
    fn foo();
}

trait B: A {
}

struct BImpl {
    unused: int
}

impl BImpl: B {
}

impl BImpl: A {
    fn foo() {}
}

struct CImpl {
    b: B
}

impl CImpl: A {
    fn foo() {
        self.b.foo();
    }
}

fn main() {
    let b = BImpl { unused: 0 } as B;
    let c = CImpl { b: b };
    c.foo();
}
[jdm@rosencrantz traitinheritance]$ rustc test2.rs 
test2.rs:25:8: 25:21 error: type `@B` does not implement any method in scope named `foo`
test2.rs:25         self.b.foo();
                    ^~~~~~~~~~~~~
@jdm

This comment has been minimized.

Show comment Hide comment
@jdm

jdm Dec 27, 2012

Contributor

Here's a simpler testcase:

trait A {
    fn foo();
}

trait B: A {
}

impl int: A {
    fn foo() {}
}

impl int: B {
}

fn main() {
    5.foo();
    (5 as B).foo();
}
[jdm@rosencrantz traitinheritance]$ rustc test3.rs 
test3.rs:33:4: 33:19 error: type `@B` does not implement any method in scope named `foo`
test3.rs:33     (5 as B).foo();
                ^~~~~~~~~~~~~~~
Contributor

jdm commented Dec 27, 2012

Here's a simpler testcase:

trait A {
    fn foo();
}

trait B: A {
}

impl int: A {
    fn foo() {}
}

impl int: B {
}

fn main() {
    5.foo();
    (5 as B).foo();
}
[jdm@rosencrantz traitinheritance]$ rustc test3.rs 
test3.rs:33:4: 33:19 error: type `@B` does not implement any method in scope named `foo`
test3.rs:33     (5 as B).foo();
                ^~~~~~~~~~~~~~~

@ghost ghost assigned catamorphism Feb 20, 2013

@catamorphism

This comment has been minimized.

Show comment Hide comment
@catamorphism

catamorphism Mar 21, 2013

Contributor

Reproduced with 373504 but not critical for 0.6.

Contributor

catamorphism commented Mar 21, 2013

Reproduced with 373504 but not critical for 0.6.

@jdm

This comment has been minimized.

Show comment Hide comment
@jdm

jdm Mar 21, 2013

Contributor

I guess this is the same as #4100.

Contributor

jdm commented Mar 21, 2013

I guess this is the same as #4100.

@jdm jdm closed this Mar 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment