diff options
| author | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-08-17 10:44:52 -0700 |
|---|---|---|
| committer | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-08-17 11:04:53 -0700 |
| commit | 280dfd2d29c7c7adeeef9b02f85a101ea3a5bde6 (patch) | |
| tree | 0a16a2dd35b2c06fba8bfc9b22633bc27b9d80b4 /src | |
| parent | 3a5c7f52cc089214c936f409b3f97d6bda377d84 (diff) | |
| download | rust-280dfd2d29c7c7adeeef9b02f85a101ea3a5bde6.tar.gz rust-280dfd2d29c7c7adeeef9b02f85a101ea3a5bde6.zip | |
Default methods with self-calls make it as far as trans.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustc/middle/typeck/check/method.rs | 20 | ||||
| -rw-r--r-- | src/test/run-pass/traits-default-method-self.rs | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 4e47b752449..9dd2cec043c 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -140,6 +140,26 @@ struct lookup { ty::ty_class(did, substs) => { self.add_candidates_from_class(did, substs); } + ty::ty_self => { + // Call is of the form "self.foo()" and appears in one + // of a trait's provided methods. + let self_def_id = match self.fcx.self_info { + some(self_info) => self_info.def_id, + none => { + // Shouldn't happen; there should always be a + // self_info in this case. + self.tcx().sess.bug(~"unexpected `none` for self_info") + } + }; + + let substs = { + self_r: none, + self_ty: none, + tps: ~[], + }; + + self.add_candidates_from_trait(self_def_id, substs); + } _ => () } diff --git a/src/test/run-pass/traits-default-method-self.rs b/src/test/run-pass/traits-default-method-self.rs index 0c4c993611f..c1ecaa5fa15 100644 --- a/src/test/run-pass/traits-default-method-self.rs +++ b/src/test/run-pass/traits-default-method-self.rs @@ -1,8 +1,6 @@ //xfail-test -// Right now, this fails with "attempted access of field `purr` on -// type `self`, but no public field or method with that name was -// found". +// Currently failing with an ICE in trans. trait Cat { fn meow() -> bool; |
