@@ -1731,9 +1731,11 @@ namespace {
17311731 };
17321732
17331733 // 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);
17371739 CS.addConstraint (ConstraintKind::LiteralConformsTo, contextualType,
17381740 arrayProto->getDeclaredInterfaceType (),
17391741 locator);
@@ -1841,9 +1843,11 @@ namespace {
18411843
18421844 // If a contextual type exists for this expression and is a dictionary
18431845 // 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);
18471851 Type contextualDictionaryKeyType;
18481852 Type contextualDictionaryValueType;
18491853 std::tie (contextualDictionaryKeyType,
0 commit comments