mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Handle invalid type specializations
If the base type of the specialization is invalid, the AST node is going to be replaced with `ErrorExpr`. We need to handle that gracefully when attempting to apply specialization in such situations. Resolves: https://github.com/swiftlang/swift/issues/77644
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// rdar://139913219 - Make sure we don't crash.
|
||||
|
||||
@@ -6,9 +6,6 @@ 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}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user