Skip to content

Commit 1ab4511

Browse files
authored
Merge pull request #36697 from slavapestov/unsubstitutable-sil-function-type
AST: Skip requirement checks in IsBindableVisitor::visitBoundGenericType() if substituted type is an interface type
2 parents 04e4d97 + 6e63486 commit 1ab4511

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/AST/Type.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,9 +1834,6 @@ class IsBindableVisitor
18341834
if (nom->getDecl() != substNom->getDecl())
18351835
return CanType();
18361836

1837-
if (nom->getDecl()->isInvalid())
1838-
return CanType();
1839-
18401837
// Same decl should always either have or not have a parent.
18411838
assert((bool)nom->getParent() == (bool)substNom->getParent());
18421839

@@ -2078,8 +2075,6 @@ class IsBindableVisitor
20782075
return CanType();
20792076

20802077
auto *decl = bgt->getDecl();
2081-
if (decl->isInvalid())
2082-
return CanType();
20832078

20842079
auto *moduleDecl = decl->getParentModule();
20852080
auto origSubMap = bgt->getContextSubstitutionMap(
@@ -2139,6 +2134,12 @@ class IsBindableVisitor
21392134
if (req.getKind() != RequirementKind::Conformance) continue;
21402135

21412136
auto canTy = req.getFirstType()->getCanonicalType();
2137+
2138+
// If the substituted type is an interface type, we can't verify the
2139+
// generic requirements.
2140+
if (canTy.subst(substSubMap)->isTypeParameter())
2141+
continue;
2142+
21422143
auto *proto = req.getProtocolDecl();
21432144
auto origConf = origSubMap.lookupConformance(canTy, proto);
21442145
auto substConf = substSubMap.lookupConformance(canTy, proto);

validation-test/compiler_crashers_2/sr13849.swift renamed to validation-test/compiler_crashers_2_fixed/sr13849.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend -emit-ir %s
1+
// RUN: %target-swift-frontend -emit-ir %s
22

33
public protocol Prot {
44
associatedtype T

0 commit comments

Comments
 (0)