Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Inheritance on self doesn't work right in default methods #3979

Closed
catamorphism opened this Issue Nov 16, 2012 · 6 comments

Comments

Projects
None yet
2 participants
Contributor

catamorphism commented Nov 16, 2012

This should work:

trait Positioned {
  fn SetX(int);
}

trait Movable: Positioned {
  fn translate(dx: int) {
    self.SetX(self.X() + dx);
  }
}

It fails to typecheck:

src/test/run-pass/issue-2616.rs:13:4: 13:13 error: attempted access of field `SetX` on type `self`,
but no field or method with that name was found
/Users/tchevalier/rust2/src/test/run-pass/issue-2616.rs:13     self.SetX(self.X() + dx);
Contributor

catamorphism commented Dec 24, 2012

I've almost fixed this -- I just ran into another incomplete bit of code in trans that I want to fix too.

@catamorphism catamorphism was assigned Dec 24, 2012

@catamorphism catamorphism added a commit to catamorphism/rust that referenced this issue Jan 21, 2013

@catamorphism catamorphism Handle supertrait calls in default methods
Add a new method_super origin for supertrait methods. Also make
coherence create a table that maps pairs of trait IDs and self types
to impl IDs, so that it's possible to check a supertrait method
knowing only its index in its trait's methods (without knowing all
supertraits for a given trait).

As per #3979
d78265a
Contributor

jbclements commented Apr 18, 2013

@catamorphism : there's a test for this, issue-3979-generics.rs. It had bit-rotted a bit, but after replacing impl Ty : Tr with impl Tr for Ty, I'm now getting an ICE. Should I re-open this bug, or is this an unrelated bug?

Contributor

catamorphism commented Apr 18, 2013

@jbclements Reopen or open a new bug if you're not sure it's the same ICE, either way :-)

Contributor

jbclements commented Apr 18, 2013

On Apr 18, 2013, at 2:39 PM, Tim Chevalier wrote:

@jbclements Reopen or open a new bug if you're not sure it's the same ICE, either way :-)

Decisions, darn it, I want decisions! :)

Ah well.

John

Contributor

catamorphism commented Apr 18, 2013

Well, I didn't see the error, and recreating it would require effort ;-)

Contributor

catamorphism commented Apr 18, 2013

(so I don't know whether or not it's the same error)

@catamorphism catamorphism removed their assignment Jun 16, 2014

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