Skip to content

Commit 4767552

Browse files
committed
---
yaml --- r: 8104 b: refs/heads/snap-stage3 c: 6ed8d03 h: refs/heads/master v: v3
1 parent ac635a0 commit 4767552

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d1158ca333fe6a982936bf69eeeaabaf21460911
4+
refs/heads/snap-stage3: 6ed8d037841aab1b2855525bf141c5c1c4de4910
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/comp/middle/typeck.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
366366

367367
fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
368368
-> ty::ty_param_bounds_and_ty {
369+
alt tcx.tcache.find(local_def(it.id)) {
370+
some(tpt) { ret tpt; }
371+
_ {}
372+
}
369373
alt it.node {
370374
ast::item_const(t, _) {
371375
let typ = ast_ty_to_ty(tcx, mode, t);
@@ -740,6 +744,16 @@ mod collect {
740744
write_ty(cx.tcx, variant.node.id, result_ty);
741745
}
742746
}
747+
fn ensure_iface_methods(tcx: ty::ctxt, id: ast::node_id) {
748+
alt tcx.items.get(id) {
749+
ast_map::node_item(@{node: ast::item_iface(_, ms), _}, _) {
750+
ty::store_iface_methods(tcx, id, @vec::map(ms, {|m|
751+
ty_of_ty_method(tcx, m_collect, m)
752+
}));
753+
}
754+
_ { fail; }
755+
}
756+
}
743757
fn convert(cx: @ctxt, it: @ast::item) {
744758
alt it.node {
745759
// These don't define types.
@@ -771,6 +785,9 @@ mod collect {
771785
{bounds: i_bounds, ty: iface_ty});
772786
alt ty::struct(cx.tcx, iface_ty) {
773787
ty::ty_iface(did, tys) {
788+
if did.crate == ast::local_crate {
789+
ensure_iface_methods(cx.tcx, did.node);
790+
}
774791
for if_m in *ty::iface_methods(cx.tcx, did) {
775792
alt vec::find(my_methods,
776793
{|m| if_m.ident == m.mty.ident}) {
@@ -827,9 +844,7 @@ mod collect {
827844
ast::item_iface(_, ms) {
828845
let tpt = ty_of_item(cx.tcx, m_collect, it);
829846
write_ty(cx.tcx, it.id, tpt.ty);
830-
ty::store_iface_methods(cx.tcx, it.id, @vec::map(ms, {|m|
831-
ty_of_ty_method(cx.tcx, m_collect, m)
832-
}));
847+
ensure_iface_methods(cx.tcx, it.id);
833848
}
834849
_ {
835850
// This call populates the type cache with the converted type
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Issue #1761
2+
3+
impl of foo for int { fn foo() -> int { 10 } }
4+
iface foo { fn foo() -> int; }
5+
fn main() {}

0 commit comments

Comments
 (0)