Skip to content

Commit cb3dcbe

Browse files
committed
Sema: Fix crash when inferring pattern type with bad conformances
Again, no test case -- this was an old radar with a -parse-stdlib example, and I'm just making this change to verify that the original crash was fixed.
1 parent 1975b10 commit cb3dcbe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,8 +2185,15 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
21852185
options |= TR_EditorPlaceholder;
21862186
}
21872187

2188+
// FIXME: initTy should be the same as resultTy; now that typeCheckExpression()
2189+
// returns a Type and not bool, we should be able to simplify the listener
2190+
// implementation here.
2191+
auto initTy = listener.getInitType();
2192+
if (initTy->hasDependentMember())
2193+
return true;
2194+
21882195
// Apply the solution to the pattern as well.
2189-
if (coercePatternToType(pattern, DC, listener.getInitType(), options,
2196+
if (coercePatternToType(pattern, DC, initTy, options,
21902197
nullptr, TypeLoc(), listener.isInOut())) {
21912198
return true;
21922199
}

0 commit comments

Comments
 (0)