Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use As and ImplicitAs interfaces for conversions. #4209

Merged
merged 17 commits into from
Sep 5, 2024

Conversation

zygoloid
Copy link
Contributor

@zygoloid zygoloid commented Aug 9, 2024

Add these interfaces to the core library. For now, they're two separate interfaces because we don't yet support one interface extending another.

This collapses a lot of the layering in check: for example, the call building logic depends on implicit conversions, conversions now depend on the overloaded operator machinery, and that machinery depends on building calls.

In passing, improve the diagnostics for failing to find a name required from the prelude. Also convert all the transitively-called code from NodeId to LocId given the latter is what the conversion machinery has available.

Copy link
Contributor

@jonmeow jonmeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, although there's a lot more reuse of locations, which got me to look at the TODO that'd hamper that. #4211 for the relevant changes.

I'm approving, if you want to merge before heading out and leave the locations for me to clean up, that's fine by me. Though if you object to the location stuff, please comment on #4211 before going. :)

toolchain/sem_ir/typed_insts.h Outdated Show resolved Hide resolved
toolchain/check/call.cpp Show resolved Hide resolved
toolchain/check/operator.h Outdated Show resolved Hide resolved
toolchain/check/operator.h Outdated Show resolved Hide resolved
toolchain/check/context.h Outdated Show resolved Hide resolved
toolchain/check/context.cpp Outdated Show resolved Hide resolved
toolchain/check/context.cpp Outdated Show resolved Hide resolved
toolchain/check/context.cpp Outdated Show resolved Hide resolved
toolchain/check/member_access.cpp Outdated Show resolved Hide resolved
@zygoloid

This comment was marked as resolved.

@@ -23,6 +23,8 @@ ExitingStream::~ExitingStream() {

auto ExitingStream::Done() -> void {
buffer_ << "\n";
buffer_.flush();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this come up for the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lifetime issue with the array of interface arguments caused the tests to fail with opt builds but not with dbg or fastbuild, and the opt builds also seemed to lose the end of the check failure diagnostic if I didn't explicitly flush the stream.

toolchain/check/context.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@jonmeow jonmeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving this a fresh look because it's been a bit, sorry if I've touched on things that were sitting around for a bit.

toolchain/check/convert.cpp Show resolved Hide resolved
toolchain/check/context.cpp Outdated Show resolved Hide resolved
github-merge-queue bot pushed a commit that referenced this pull request Sep 5, 2024
Conversion can trigger new entities to be imported, which can invalidate
the reference it holds to an EntityWithParamBase. Instead of holding
such a reference, pull the information we need out of the entity early
and only pass that into ConvertCallArgs.

I couldn't find a good standalone way to test this, but this fixes the
test failure we otherwise see on MacOS after #4209, so it will be tested
once that PR lands.
Copy link
Contributor

@jonmeow jonmeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Glad to get this in. :)

@jonmeow jonmeow added this pull request to the merge queue Sep 5, 2024
Merged via the queue into carbon-language:trunk with commit 187a360 Sep 5, 2024
8 checks passed
dwblaikie pushed a commit to dwblaikie/carbon-lang that referenced this pull request Sep 6, 2024
…4277)

Conversion can trigger new entities to be imported, which can invalidate
the reference it holds to an EntityWithParamBase. Instead of holding
such a reference, pull the information we need out of the entity early
and only pass that into ConvertCallArgs.

I couldn't find a good standalone way to test this, but this fixes the
test failure we otherwise see on MacOS after carbon-language#4209, so it will be tested
once that PR lands.
dwblaikie pushed a commit to dwblaikie/carbon-lang that referenced this pull request Sep 6, 2024
…e#4209)

Add these interfaces to the core library. For now, they're two separate
interfaces because we don't yet support one interface extending another.

This collapses a lot of the layering in check: for example, the call
building logic depends on implicit conversions, conversions now depend
on the overloaded operator machinery, and that machinery depends on
building calls.

In passing, improve the diagnostics for failing to find a name required
from the prelude. Also convert all the transitively-called code from
`NodeId` to `LocId` given the latter is what the conversion machinery
has available.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
dwblaikie pushed a commit to dwblaikie/carbon-lang that referenced this pull request Sep 9, 2024
…4277)

Conversion can trigger new entities to be imported, which can invalidate
the reference it holds to an EntityWithParamBase. Instead of holding
such a reference, pull the information we need out of the entity early
and only pass that into ConvertCallArgs.

I couldn't find a good standalone way to test this, but this fixes the
test failure we otherwise see on MacOS after carbon-language#4209, so it will be tested
once that PR lands.
dwblaikie pushed a commit to dwblaikie/carbon-lang that referenced this pull request Sep 9, 2024
…e#4209)

Add these interfaces to the core library. For now, they're two separate
interfaces because we don't yet support one interface extending another.

This collapses a lot of the layering in check: for example, the call
building logic depends on implicit conversions, conversions now depend
on the overloaded operator machinery, and that machinery depends on
building calls.

In passing, improve the diagnostics for failing to find a name required
from the prelude. Also convert all the transitively-called code from
`NodeId` to `LocId` given the latter is what the conversion machinery
has available.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
@zygoloid zygoloid deleted the toolchain-convert-interfaces branch September 16, 2024 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants