swift
e28605c0 - [cxx-interop] Allow using `std::map` subscript

Commit
3 years ago
[cxx-interop] Allow using `std::map` subscript This fixes an error that occurred when trying to use the subscript on an instance `std::map`: ``` error: cannot assign through subscript: 'map' is immutable ``` This was happening even with a mutable `std::map` instance. `std::map::operator[]` has two overloads: * `T& operator[]( const Key& key )` * `T& operator[]( Key&& key )` The second one is imported with an `inout` parameter, and we picked it as an implementation of the subscript getter because it was the last of the two overloads to get imported. Swift does not allow subscripts with `inout` parameters. This is checked at the AST level, and those checks do not run for synthesized Swift code. This caused Swift to produce a surprising error which actually indicated that the argument of the subscript, not the instance itself, must be mutable. rdar://100529571
Author
Committer
Parents
Loading