Skip to content

[CSSimplify] Handle invalid type specializations #77652

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

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13936,6 +13936,13 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
} else {
// If the overload hasn't been resolved, we can't simplify this constraint.
auto overloadLocator = getCalleeLocator(getConstraintLocator(locator));

// If there was a problem resolving specialization expression
// it would be diagnosted as invalid AST node.
if (overloadLocator->directlyAt<ErrorExpr>()) {
return shouldAttemptFixes() ? SolutionKind::Error : SolutionKind::Solved;
}

auto selectedOverload = findSelectedOverloadFor(overloadLocator);
if (!selectedOverload)
return formUnsolved();
Expand Down
5 changes: 1 addition & 4 deletions test/Constraints/rdar139913219.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// RUN: %target-typecheck-verify-swift

// rdar://139913219 - Make sure we don't crash.

func bar(_ x: Int.Type, _: Int) {}
func bar<T>(_ x: T.Type, _: Int) {}

func foo() {
// FIXME: We shouldn't be failing to produce a diagnostic.
// Once resolved, remove '-verify-ignore-unknown'
bar(X<Int?>.self, .zero)
// expected-error@-1 {{cannot find 'X' in scope}}
// expected-error@-2 {{failed to produce diagnostic for expression}}
}