Files
carbon-lang/toolchain/check/testdata
Dana JansensandRichard Smith c59ceb1f7b Support builtin conversions of adapter classes (#4655)
When creating a tuple or struct type object/value, we will walk each of
the tuple's or struct's parts, respectively, and Convert() each of them.
This allows (T, T) to convert to (U, U) and so forth. It also performs
the conversion from value to initialization even for the same types,
such as converting from a value of (T, T) to an object of (T, T).

Classes need to define their own conversions but when the target and
source types are the same, there is no conversion of types taking place.
If the class adapts a tuple or struct then walk each of the tuple's or
struct's parts, respectively, and Convert() each of them in order to
initialize the parts of the target.

For copyable types, the conversion implies a copy in the initialization,
and for non-copyable types, an error is emitted.

This supports copying a class value to a class object when it is an
adapter of a tuple or struct.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2025-01-06 16:23:32 +00:00
..
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00
2025-01-02 23:03:11 +00:00