microsoft / microsoft/typespec
`@overload` should not be restricted to operations in the same interface/namespace
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
When the feature was added, concerns were accidental overloads/overloads not known by the service author.
However, as we introduced client sidecars, we have a class of use cases where *the whole point* of their existence is to augment service definitions, and the restriction is just getting in the way.
As an example:
```cadl
import "@cadl-lang/rest";
using Cadl.Http;
namespace Service {
model SometingComplicated {
id: string;
input: string | string[];
stuff?: Record;
}
@post op doStuff(...SometingComplicated): void;
}
namespace ClientSideCar {
@overload(Service.doStuff)
@post op doSingleStuff(id: string, input: string): void;
@overload(Service.doStuff)
@post op doMultiStuff(id: string, input: string[], stuff?: Record): void;
}
```
While I could drop the overload, I would miss the super-nice subtype calculation/validation that the compiler gives me.
[playground](https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAY2FkbC1sYW5nL3Jlc3QiOwoKdXNpbmcgQ2FkbC5IdHRwOwoKbmFtZXNwYWNlIFNlcnZpY2UgewoKICBtb2RlbCBTb21ldGluZ0NvbXBsaWNhdGVkIHsKICAgIGlkOiBzdHJpbmc7xhBucHV0yBMgfMcJW13GHnN0dWZmPzogUmVjb3JkPMYdPjvEaX3EBUBwb3N0IG9wIGRvU8QrKC4uLtN8KTogdm9pZDsKfewAuENsaWVudOUAmEBvdmVybG9hZCjnAM0ux1Epz2VpbmdsZcZr6gDKLO4Axslu31nMWU11bHRp31hbXSz3ARHJcn0%3D)
Contributor guide
Assessment
This issue has not been assessed yet.