r? @nikomatsakis This patch causes self to be inherited from the enclosing function context when typechecking nested closures, allowing default methods to call inherited methods on self. This is effectively treating self like it has dynamic scope, for the purposes of typechecking. I think it should be sound to do so, since any incorrect uses of self would already have been flagged by resolve.
This addresses #3563.
Improve a typeck ICE
Suppress error messages about function types whose result is ty_err
Ideally we would suppress error messages involving any types that
contain ty_err, but that's awkward to do right now.
Treat `self` as if it's dynamically scoped when typechecking nested f…
Necessary to allow supertrait methods to be called in default functions.
As per #3563
oops, memo to self: rebase this before committing, it really needs to be part of be06a3e
Let me think about this more carefully for a sec, but it looks correct.
One caveat: this is not dynamic scoping. Dynamic scoping would mean that the body of some called function would see values set by the caller --- but this is just saying that self is available as an upvar to closures within, which I think is reasonable. In fact it's already the case, but incompletely, which is what you're fixing I guess.
r+ --- I think this is reasonable.
Merged - 80435ad