Issue 10329 - Attributes not inferred for indirectly templated methods

https://d.puremagic.com/issues/show_bug.cgi?id=10329

This is the last step for the pure/@safe algorithms and ranges.

Except following two cases, all of instantiated function attributes will be inferred.

1. Virtual methods

    ```d
    class C(T) {
        void foo() {}
    }
    pragma(msg, typeof(&C!int.foo));    // void function()
    ```

2. Non-eponymous functions which declared in template scope

    ```d
    template X(T) {
        void foo(T) {}
    }
    pragma(msg, typeof(&X!int.foo));    // void function(int)
    ```

    (I'm not still sure this is an essential restriction, but currently it's necessary to avoid [bug 10134](https://d.puremagic.com/issues/show_bug.cgi?id=10134)).

After merging this PR, for example, following code will be runnable with git-head Phobos.

```d
import std.algorithm, std.range;
void main() pure @safe
{
    int[][] ror =[[1,2,3]];
    auto r = joiner(ror);

    string res;
    foreach (e; chain("a", "b"))
        res ~= e;
    assert(res == "ab");
}
```