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

Fix contract in AngularJS plugin. #899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jesyspa
Copy link

@jesyspa jesyspa commented Nov 10, 2023

The contract for processTupleArgument is meant to say that the function will not return a non-null value if nullIfNotFound = false. However, the old contract said the opposite: that if the function returned a non-null value, then nullIfNotFound = false, which is not true (if the value is found, nullIfNotFound plays no role).

At the moment, the compiler cannot use either contract meaningfully so the difference is immaterial. If https://youtrack.jetbrains.com/issue/KT-63378/Support-or-prohibit-contracts-that-use-Boolean-parameters-on-the-right-of-an-implies is resolved and support for this is added, the new contract will allow the call-sites that pass nullIfNotFound = false to perform a smart cast to List<R> instead of having to use !!.

The contract for `processTupleArgument` is meant to say that the
function will not return a non-null value if `nullIfNotFound = false`.
However, the old contract said the opposite: that if the function
returned a non-null value, then `nullIfNotFound = false`, which is not
true (if the value is found, `nullIfNotFound` plays no role).

At the moment, the compiler cannot use either contract meaningfully so
the difference is immaterial.  If https://youtrack.jetbrains.com/issue/KT-63378/Support-or-prohibit-contracts-that-use-Boolean-parameters-on-the-right-of-an-implies
is resolved and support for this is added, the new contract will allow
the call-sites that pass `nullIfNotFound = false` to perform a smart
cast to `List<R>` instead of having to use `!!`.
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.

1 participant