Skip to content

Commit 698dd39

Browse files
authored
Merge pull request #19554 from xedin/rdar-44770297
[CSBindings] Don't consider dependent member types even if they are w…
2 parents dc8a0ac + bd527c1 commit 698dd39

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ Optional<Type> ConstraintSystem::checkTypeOfBinding(TypeVariableType *typeVar,
118118
return None;
119119
}
120120

121-
// Don't bind to a dependent member type.
122-
if (type->is<DependentMemberType>()) return None;
121+
// Don't bind to a dependent member type, even if it's currently
122+
// wrapped in any number of optionals, because binding producer
123+
// might unwrap and try to attempt it directly later.
124+
if (type->lookThroughAllOptionalTypes()->is<DependentMemberType>())
125+
return None;
123126

124127
// Okay, allow the binding (with the simplified type).
125128
return type;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
3+
protocol P {
4+
associatedtype A
5+
}
6+
7+
func foo<T: P>(_: () throws -> T) -> T.A? {
8+
fatalError()
9+
}
10+
11+
_ = foo() { fatalError() } & nil

0 commit comments

Comments
 (0)