<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/136472>136472</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang errors for out-of-line definition with deducing-this of non-templated type nested within templated type
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          scrossuk
      </td>
    </tr>
</table>

<pre>
    Given this code:

```
template <typename T>
struct Type final
{
    struct Nested
    {
        void method(this auto& self);
    };
};

template <typename T>
void Type<T>::Nested::method(this auto& self) {}
```

Clang reports ([Godbolt](https://godbolt.org/z/9MqhEGPsK)):

```
<source>:11:30: error: an explicit object parameter cannot appear in a non-member function
 11 | void Type<T>::Nested::method(this auto& self) {}
```

Note that a work around is to make the nested type also be a template ([Godbolt](https://godbolt.org/z/WWjKe5WPv)):

```
template <typename T>
struct Type final
{
    template <typename Unused>
    struct Nested
 {
        void method(this auto& self);
    };
};

template <typename T>
template <typename Unused>
void Type<T>::Nested<Unused>::method(this auto& self) {}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VEFv8zYM_TX0hUggy3YcH3xwkqaHYkUPHXqWbTpWK0ueJKfrfv0gx1uwosuwAt8XCAgtiuLjI5-Ec_KkiUrIdpAdIjH53tjSNdY4N71FtWk_ynt5Jo2-lw4b0xIkFbB5bdiyWOVpGJXwhJDs_cdIWgyEz5DcAauct1Pj8fljJOykFirE5jtgFSLi4n0k56ld9q7e8Dsb2eJAvjct8O2MQ0zeAN-gI9UBLyDZ_R15uHxcjdvg5ssDNEj281ZSQVItaGb7ZuYZan74xAawaq-EPqGl0VjvEPgWst29aWujPGQH4Nve-9GFDPwI_Hi6uNbGnoAf_wB-LH75rb-7f3IPob5Q4hesQ7J3ZrINXYDHMSRVwiCpkKw1NhhCI_0-KtlIj6Z-pcbjKKwYyJPFRmhtPIpxJGFRahSojV4NNNRksZt046XRgdo4Rsj3-KPYejSe0PfCo8B3Y99QWDPpFqVDb3AQb8FLqOdEGHqIQjmDNaHAa3v_P8svL68PlL08nW-w_P3Z_jLyVz25wNbdvwngJ07_fwK83fD99ei3mh-1ZdIWSSEiKuM8zWKesnwb9WVcC0bEc8rquOiKjOVx3mw3fFPzIhWCIllyxjOWcsbSNI63a74hirt6223yLi-KBFJGg5BqrdR5CA2PpHMTlXGySXMeKVGTcvOzx3kTtAqchxfQliFgVU8nBylT0nl3vcJLr6i8SHtWmMPOWDSTX5lupaQmbKmTWgbZ4Lv0PbbUTo3Up9VMielmgf1F-zLKy1iH81LjP53RZFX5aYql76d63ZgB-DFgW_5WozVB4MCPc60O-HEp91zyPwMAAP__LDXN4A">