@@ -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 visitObjectLiteralExpr (ObjectLiteralExpr *E);
243
242
244
243
bool visitApplyExpr (ApplyExpr *AE);
245
244
bool visitRebindSelfInConstructorExpr (RebindSelfInConstructorExpr *E);
@@ -1722,74 +1721,6 @@ visitRebindSelfInConstructorExpr(RebindSelfInConstructorExpr *E) {
1722
1721
return false ;
1723
1722
}
1724
1723
1725
- // / When an object literal fails to typecheck because its protocol's
1726
- // / corresponding default type has not been set in the global namespace (e.g.
1727
- // / _ColorLiteralType), suggest that the user import the appropriate module for
1728
- // / the target.
1729
- bool FailureDiagnosis::visitObjectLiteralExpr (ObjectLiteralExpr *E) {
1730
- // Type check the argument first.
1731
- auto protocol = TypeChecker::getLiteralProtocol (CS.getASTContext (), E);
1732
- if (!protocol)
1733
- return false ;
1734
- auto constrName =
1735
- TypeChecker::getObjectLiteralConstructorName (CS.getASTContext (), E);
1736
- assert (constrName);
1737
- auto *constr = dyn_cast_or_null<ConstructorDecl>(
1738
- protocol->getSingleRequirement (constrName));
1739
- if (!constr)
1740
- return false ;
1741
- auto paramType = TypeChecker::getObjectLiteralParameterType (E, constr);
1742
- if (!typeCheckChildIndependently (
1743
- E->getArg (), paramType, CTP_CallArgument))
1744
- return true ;
1745
-
1746
- // Conditions for showing this diagnostic:
1747
- // * The object literal protocol's default type is unimplemented
1748
- if (TypeChecker::getDefaultType (protocol, CS.DC ))
1749
- return false ;
1750
- // * The object literal has no contextual type
1751
- if (CS.getContextualType ())
1752
- return false ;
1753
-
1754
- // Figure out what import to suggest.
1755
- auto &Ctx = CS.getASTContext ();
1756
- const auto &target = Ctx.LangOpts .Target ;
1757
- StringRef importModule;
1758
- StringRef importDefaultTypeName;
1759
- if (protocol == Ctx.getProtocol (KnownProtocolKind::ExpressibleByColorLiteral)) {
1760
- if (target.isMacOSX ()) {
1761
- importModule = " AppKit" ;
1762
- importDefaultTypeName = " NSColor" ;
1763
- } else if (target.isiOS () || target.isTvOS ()) {
1764
- importModule = " UIKit" ;
1765
- importDefaultTypeName = " UIColor" ;
1766
- }
1767
- } else if (protocol == Ctx.getProtocol (
1768
- KnownProtocolKind::ExpressibleByImageLiteral)) {
1769
- if (target.isMacOSX ()) {
1770
- importModule = " AppKit" ;
1771
- importDefaultTypeName = " NSImage" ;
1772
- } else if (target.isiOS () || target.isTvOS ()) {
1773
- importModule = " UIKit" ;
1774
- importDefaultTypeName = " UIImage" ;
1775
- }
1776
- } else if (protocol == Ctx.getProtocol (
1777
- KnownProtocolKind::ExpressibleByFileReferenceLiteral)) {
1778
- importModule = " Foundation" ;
1779
- importDefaultTypeName = " URL" ;
1780
- }
1781
-
1782
- // Emit the diagnostic.
1783
- const auto plainName = E->getLiteralKindPlainName ();
1784
- Ctx.Diags .diagnose (E->getLoc (), diag::object_literal_default_type_missing,
1785
- plainName);
1786
- if (!importModule.empty ()) {
1787
- Ctx.Diags .diagnose (E->getLoc (), diag::object_literal_resolve_import,
1788
- importModule, importDefaultTypeName, plainName);
1789
- }
1790
- return true ;
1791
- }
1792
-
1793
1724
bool FailureDiagnosis::diagnoseMemberFailures (
1794
1725
Expr *E, Expr *baseExpr, ConstraintKind lookupKind, DeclNameRef memberName,
1795
1726
FunctionRefKind funcRefKind, ConstraintLocator *locator,
0 commit comments