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

Introduce workaround (in fact, fix the previously incorrect expect-ac… #3850

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

qwwdfsad
Copy link
Collaborator

@qwwdfsad qwwdfsad commented Aug 14, 2023

…tual mapping) for CancellationException.

See KT-61168 for the root cause & KT-22004 for the future solution

…tual mapping) for CancellationException.

See KT-61168
Comment on lines +19 to +21
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun CancellationException(message: String?, cause: Throwable?): CancellationException =
CancellationException(message, cause)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this LowPriorityInOverloadResolution just to make this definition work, or is it also so that platform-specific code chooses the other overload?

  • If it's for the definition to work, won't a fully-qualified name work better? Like = kotlin.coroutines.cancellation.CancellationException(message, cause).
  • If it's for choosing the other overload, maybe we can ensure this also happens on K2 by marking this function as inline? Is this possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To make the declaration work (otherwise, it's conflicting overloads on the declaration level) and, later, the choice of the overload from our/users' code.

maybe we can ensure this also happens on K2 by marking this function as inline?

It's a bit unclear to me what you've meant, could you please elaborate on that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit unclear to me what you've meant, could you please elaborate on that?

If I remember correctly, with K2, in common code, the overload that gets chosen in the end is the common one, so in this case, the expect function. If that's undesirable, can't we mark this function as inline instead so its calls always get converted to the ones we want?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see, thanks.

the overload that gets chosen in the end is the common one

Unfortunately, it will be the case only for the code in kotlinx-coroutines-core sourceset and not for our users, so I don't think it worth it

Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

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

I can't say that I fully got it, but this seems fine.

@dkhalanskyjb
Copy link
Collaborator

Ok, now I got it. It is as good as it gets, I think.

@qwwdfsad qwwdfsad merged commit 7659d65 into develop Sep 20, 2023
1 check passed
@qwwdfsad qwwdfsad deleted the wa-for-kt-61168 branch September 20, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants