@@ -1731,9 +1731,11 @@ namespace {
1731
1731
};
1732
1732
1733
1733
// If a contextual type exists for this expression, apply it directly.
1734
- Optional<Type> arrayElementType;
1735
- if (contextualType &&
1736
- (arrayElementType = ConstraintSystem::isArrayType (contextualType))) {
1734
+ if (contextualType && ConstraintSystem::isArrayType (contextualType)) {
1735
+ contextualType = CS.replaceInferableTypesWithTypeVars (
1736
+ contextualType, CS.getConstraintLocator (expr));
1737
+ Optional<Type> arrayElementType =
1738
+ ConstraintSystem::isArrayType (contextualType);
1737
1739
CS.addConstraint (ConstraintKind::LiteralConformsTo, contextualType,
1738
1740
arrayProto->getDeclaredInterfaceType (),
1739
1741
locator);
@@ -1841,9 +1843,11 @@ namespace {
1841
1843
1842
1844
// If a contextual type exists for this expression and is a dictionary
1843
1845
// type, apply it directly.
1844
- Optional<std::pair<Type, Type>> dictionaryKeyValue;
1845
- if (openedType && (dictionaryKeyValue =
1846
- ConstraintSystem::isDictionaryType (openedType))) {
1846
+ if (openedType && ConstraintSystem::isDictionaryType (openedType)) {
1847
+ openedType = CS.replaceInferableTypesWithTypeVars (
1848
+ openedType, CS.getConstraintLocator (expr));
1849
+ Optional<std::pair<Type, Type>> dictionaryKeyValue =
1850
+ ConstraintSystem::isDictionaryType (openedType);
1847
1851
Type contextualDictionaryKeyType;
1848
1852
Type contextualDictionaryValueType;
1849
1853
std::tie (contextualDictionaryKeyType,
0 commit comments