Skip to content

[Sema] Avoid getCalleeLocator() with inner call that is still variable type. #75664

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

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

Conversation

gregomni
Copy link
Contributor

@gregomni gregomni commented Aug 3, 2024

getCalleeLocator() at ConstraintSystem.cpp:681 asserts that the function type is not a type variable. (The assert got added after Swift 5.10 it looks like, which is why this is a regression.) In this particular spot, if there is an unresolved overload skip checking the inner overload choice, avoiding the call. (Later on when the type variable is bound, simplifying here happens again and succeeds.)

Resolves #75623.

@gregomni
Copy link
Contributor Author

gregomni commented Aug 3, 2024

@swift-ci Please smoke test.

@gregomni gregomni marked this pull request as draft August 3, 2024 05:24
@gregomni
Copy link
Contributor Author

gregomni commented Aug 3, 2024

@swift-ci Please smoke test.

@gregomni gregomni marked this pull request as ready for review August 3, 2024 18:56
@@ -2080,13 +2080,16 @@ ConstraintSystem::matchFunctionResultTypes(Type expectedResult, Type fnResult,
auto anchor = locator.getAnchor();
if (auto *callExpr = getAsExpr<CallExpr>(anchor)) {
if (auto *innerCall = getAsExpr<CallExpr>(callExpr->getSemanticFn())) {
auto *innerCalleeLoc =
if (!simplifyType(getType(innerCall->getFn()))
->is<TypeVariableType>()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is wrong for the cases with IUO because this means that the follow-up logic that checks selected overload won't have it and the solver won't potentially end up not adding disjunction for the IUO. We need a test-case that verifies that...

I think this logic needs to be moved to simplifyApplicableFnConstraint and if the inner call doesn't have an overload selected yet we need to delay simplication of ApplicableFunction constraint until it is selected.

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.

[asserts] Compiler crashing on computed property accessing a stored property with same label as static func
2 participants