Skip to content

Commit 26e888e

Browse files
authored
Merge pull request #77652 from xedin/issue-77644
[CSSimplify] Handle invalid type specializations
2 parents ff21dde + 30c1961 commit 26e888e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13935,6 +13935,13 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
1393513935
} else {
1393613936
// If the overload hasn't been resolved, we can't simplify this constraint.
1393713937
auto overloadLocator = getCalleeLocator(getConstraintLocator(locator));
13938+
13939+
// If there was a problem resolving specialization expression
13940+
// it would be diagnosted as invalid AST node.
13941+
if (overloadLocator->directlyAt<ErrorExpr>()) {
13942+
return shouldAttemptFixes() ? SolutionKind::Error : SolutionKind::Solved;
13943+
}
13944+
1393813945
auto selectedOverload = findSelectedOverloadFor(overloadLocator);
1393913946
if (!selectedOverload)
1394013947
return formUnsolved();

test/Constraints/rdar139913219.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown
1+
// RUN: %target-typecheck-verify-swift
22

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

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

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

0 commit comments

Comments
 (0)