@@ -239,7 +239,6 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
239
239
bool visitTryExpr (TryExpr *E);
240
240
241
241
bool visitUnresolvedDotExpr (UnresolvedDotExpr *UDE);
242
- bool visitArrayExpr (ArrayExpr *E);
243
242
bool visitDictionaryExpr (DictionaryExpr *E);
244
243
bool visitObjectLiteralExpr (ObjectLiteralExpr *E);
245
244
@@ -1724,60 +1723,6 @@ visitRebindSelfInConstructorExpr(RebindSelfInConstructorExpr *E) {
1724
1723
return false ;
1725
1724
}
1726
1725
1727
- bool FailureDiagnosis::visitArrayExpr (ArrayExpr *E) {
1728
- // If we had a contextual type, then it either conforms to
1729
- // ExpressibleByArrayLiteral or it is an invalid contextual type.
1730
- auto contextualType = CS.getContextualType ();
1731
- if (!contextualType) {
1732
- return false ;
1733
- }
1734
-
1735
- // If our contextual type is an optional, look through them, because we're
1736
- // surely initializing whatever is inside.
1737
- contextualType = contextualType->lookThroughAllOptionalTypes ();
1738
-
1739
- // Validate that the contextual type conforms to ExpressibleByArrayLiteral and
1740
- // figure out what the contextual element type is in place.
1741
- auto ALC =
1742
- TypeChecker::getProtocol (CS.getASTContext (), E->getLoc (),
1743
- KnownProtocolKind::ExpressibleByArrayLiteral);
1744
- if (!ALC)
1745
- return visitExpr (E);
1746
-
1747
- // Check to see if the contextual type conforms.
1748
- auto Conformance = TypeChecker::conformsToProtocol (
1749
- contextualType, ALC, CS.DC , ConformanceCheckFlags::InExpression);
1750
- if (Conformance) {
1751
- Type contextualElementType =
1752
- Conformance
1753
- .getTypeWitnessByName (contextualType,
1754
- CS.getASTContext ().Id_ArrayLiteralElement )
1755
- ->getDesugaredType ();
1756
-
1757
- // Type check each of the subexpressions in place, passing down the contextual
1758
- // type information if we have it.
1759
- for (auto elt : E->getElements ()) {
1760
- if (typeCheckChildIndependently (elt, contextualElementType,
1761
- CTP_ArrayElement) == nullptr ) {
1762
- return true ;
1763
- }
1764
- }
1765
-
1766
- return false ;
1767
- }
1768
-
1769
- ContextualFailure failure (CS, CS.getType (E), contextualType,
1770
- CS.getConstraintLocator (E));
1771
- if (failure.diagnoseConversionToDictionary ())
1772
- return true ;
1773
-
1774
- // If that didn't turn up an issue, then we don't know what to do.
1775
- // TODO: When a contextual type is missing, we could try to diagnose cases
1776
- // where the element types mismatch... but theoretically they should type
1777
- // unify to Any, so that could never happen?
1778
- return false ;
1779
- }
1780
-
1781
1726
bool FailureDiagnosis::visitDictionaryExpr (DictionaryExpr *E) {
1782
1727
Type contextualKeyType, contextualValueType;
1783
1728
auto keyTypePurpose = CTP_Unused, valueTypePurpose = CTP_Unused;
0 commit comments