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

    <tr>
        <th>Summary</th>
        <td>
            [C++20] [Modules] ADL does not work properly for dependent expressions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Given the following two valid files:

```cpp
module;

namespace n {

struct s { };

void operator+(s, int) {
}

} // namespace n

export module a;

export template<typename T>
void a(T x) {
        n::s() + x;
}
```

```cpp
module;

export module b;

import a;

void b() {
        a(0);
}
```

When compiled with

```shell
clang++ -std=c++20 -x c++-module a.cpp --precompile -o a.pcm
clang++ -std=c++20 -x c++-module b.cpp --precompile -o b.pcm -fmodule-file=a.pcm
```

causes clang to fail with

```
In file included from b.cpp:1:
a.cpp:16:9: error: invalid operands to binary expression ('n::s' and 'int')
        n::s() + x;
        ~~~~~~ ^ ~
b.cpp:8:2: note: in instantiation of function template specialization 'a<int>' requested here
        a(0);
        ^
1 error generated.
```

In practice, this comes up with code like `std::string() + some_custom_to_string(my_type)`. Calling code needs to `#include <string>` in their module, even though they know nothing about `std::string` in the called function.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclV1v6ygTxz_N5GaUyIE4Ti5ykZf20ZGevTvSXlYYxjFbDF7ATbMX57OvwHGbdrtHq2NVjWHwzI-Z-YMIQZ8t0Q7KA5SnmRhi6_xOiRetQnSWZrVT193_9AtZjC1h44xxF23PGC8OX4TRChttKADfQ3GCYvq_LsY_2ffjTOfUYAj44X6ZFR2FXkhCi1B9MIXoBxkxpHmE6vTpyxenFbqevIjOAzsA2wRgR9Q2AtveOatOH7iqEwJ7BPaId7HvV9Br73zEERfFp7A3a6SuNyIS8GO89pRc4XfgD3dsAtjmO75-hCm2NiWK7wOw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