@@ -272,7 +272,7 @@ static bool buildObjCKeyPathString(KeyPathExpr *E,
272
272
static Expr *buildDynamicMemberLookupIndexExpr (StringRef name, SourceLoc loc,
273
273
DeclContext *dc,
274
274
ConstraintSystem &cs) {
275
- auto &ctx = cs.TC . Context ;
275
+ auto &ctx = cs.getASTContext () ;
276
276
277
277
auto *stringDecl = ctx.getStringDecl ();
278
278
auto stringType = stringDecl->getDeclaredType ();
@@ -1837,12 +1837,12 @@ namespace {
1837
1837
return expr;
1838
1838
1839
1839
auto &tc = cs.getTypeChecker ();
1840
- ProtocolDecl *protocol
1841
- = tc. getProtocol ( expr->getLoc (),
1842
- KnownProtocolKind::ExpressibleByIntegerLiteral);
1843
- ProtocolDecl *builtinProtocol
1844
- = tc. getProtocol ( expr->getLoc (),
1845
- KnownProtocolKind::ExpressibleByBuiltinIntegerLiteral);
1840
+ ProtocolDecl *protocol = TypeChecker::getProtocol (
1841
+ cs. getASTContext (), expr->getLoc (),
1842
+ KnownProtocolKind::ExpressibleByIntegerLiteral);
1843
+ ProtocolDecl *builtinProtocol = TypeChecker::getProtocol (
1844
+ cs. getASTContext (), expr->getLoc (),
1845
+ KnownProtocolKind::ExpressibleByBuiltinIntegerLiteral);
1846
1846
1847
1847
// For type-sugar reasons, prefer the spelling of the default literal
1848
1848
// type.
@@ -1851,9 +1851,9 @@ namespace {
1851
1851
if (defaultType->isEqual (type))
1852
1852
type = defaultType;
1853
1853
}
1854
- if (auto floatProtocol
1855
- = tc. getProtocol ( expr->getLoc (),
1856
- KnownProtocolKind::ExpressibleByFloatLiteral)) {
1854
+ if (auto floatProtocol = TypeChecker::getProtocol (
1855
+ cs. getASTContext (), expr->getLoc (),
1856
+ KnownProtocolKind::ExpressibleByFloatLiteral)) {
1857
1857
if (auto defaultFloatType = tc.getDefaultType (floatProtocol, dc)) {
1858
1858
if (defaultFloatType->isEqual (type))
1859
1859
type = defaultFloatType;
@@ -1888,8 +1888,9 @@ namespace {
1888
1888
}
1889
1889
1890
1890
auto &tc = cs.getTypeChecker ();
1891
- auto *protocol = tc.getProtocol (expr->getLoc (),
1892
- KnownProtocolKind::ExpressibleByNilLiteral);
1891
+ auto *protocol =
1892
+ TypeChecker::getProtocol (cs.getASTContext (), expr->getLoc (),
1893
+ KnownProtocolKind::ExpressibleByNilLiteral);
1893
1894
1894
1895
// For type-sugar reasons, prefer the spelling of the default literal
1895
1896
// type.
@@ -1920,12 +1921,12 @@ namespace {
1920
1921
return expr;
1921
1922
1922
1923
auto &tc = cs.getTypeChecker ();
1923
- ProtocolDecl *protocol
1924
- = tc. getProtocol ( expr->getLoc (),
1925
- KnownProtocolKind::ExpressibleByFloatLiteral);
1926
- ProtocolDecl *builtinProtocol
1927
- = tc. getProtocol ( expr->getLoc (),
1928
- KnownProtocolKind::ExpressibleByBuiltinFloatLiteral);
1924
+ ProtocolDecl *protocol = TypeChecker::getProtocol (
1925
+ cs. getASTContext (), expr->getLoc (),
1926
+ KnownProtocolKind::ExpressibleByFloatLiteral);
1927
+ ProtocolDecl *builtinProtocol = TypeChecker::getProtocol (
1928
+ cs. getASTContext (), expr->getLoc (),
1929
+ KnownProtocolKind::ExpressibleByBuiltinFloatLiteral);
1929
1930
1930
1931
// For type-sugar reasons, prefer the spelling of the default literal
1931
1932
// type.
@@ -1964,12 +1965,12 @@ namespace {
1964
1965
return expr;
1965
1966
1966
1967
auto &tc = cs.getTypeChecker ();
1967
- ProtocolDecl *protocol
1968
- = tc. getProtocol ( expr->getLoc (),
1969
- KnownProtocolKind::ExpressibleByBooleanLiteral);
1970
- ProtocolDecl *builtinProtocol
1971
- = tc. getProtocol ( expr->getLoc (),
1972
- KnownProtocolKind::ExpressibleByBuiltinBooleanLiteral);
1968
+ ProtocolDecl *protocol = TypeChecker::getProtocol (
1969
+ cs. getASTContext (), expr->getLoc (),
1970
+ KnownProtocolKind::ExpressibleByBooleanLiteral);
1971
+ ProtocolDecl *builtinProtocol = TypeChecker::getProtocol (
1972
+ cs. getASTContext (), expr->getLoc (),
1973
+ KnownProtocolKind::ExpressibleByBuiltinBooleanLiteral);
1973
1974
if (!protocol || !builtinProtocol)
1974
1975
return nullptr ;
1975
1976
@@ -2001,24 +2002,25 @@ namespace {
2001
2002
2002
2003
bool isStringLiteral = true ;
2003
2004
bool isGraphemeClusterLiteral = false ;
2004
- ProtocolDecl *protocol = tc.getProtocol (
2005
- expr->getLoc (), KnownProtocolKind::ExpressibleByStringLiteral);
2005
+ ProtocolDecl *protocol = TypeChecker::getProtocol (
2006
+ cs.getASTContext (), expr->getLoc (),
2007
+ KnownProtocolKind::ExpressibleByStringLiteral);
2006
2008
2007
2009
if (!TypeChecker::conformsToProtocol (
2008
2010
type, protocol, cs.DC , ConformanceCheckFlags::InExpression)) {
2009
2011
// If the type does not conform to ExpressibleByStringLiteral, it should
2010
2012
// be ExpressibleByExtendedGraphemeClusterLiteral.
2011
- protocol = tc. getProtocol (
2012
- expr->getLoc (),
2013
+ protocol = TypeChecker:: getProtocol (
2014
+ cs. getASTContext (), expr->getLoc (),
2013
2015
KnownProtocolKind::ExpressibleByExtendedGraphemeClusterLiteral);
2014
2016
isStringLiteral = false ;
2015
2017
isGraphemeClusterLiteral = true ;
2016
2018
}
2017
2019
if (!TypeChecker::conformsToProtocol (
2018
2020
type, protocol, cs.DC , ConformanceCheckFlags::InExpression)) {
2019
2021
// ... or it should be ExpressibleByUnicodeScalarLiteral.
2020
- protocol = tc. getProtocol (
2021
- expr->getLoc (),
2022
+ protocol = TypeChecker:: getProtocol (
2023
+ cs. getASTContext (), expr->getLoc (),
2022
2024
KnownProtocolKind::ExpressibleByUnicodeScalarLiteral);
2023
2025
isStringLiteral = false ;
2024
2026
isGraphemeClusterLiteral = false ;
@@ -2044,8 +2046,8 @@ namespace {
2044
2046
literalFuncName = DeclName (tc.Context , DeclBaseName::createConstructor (),
2045
2047
{ tc.Context .Id_stringLiteral });
2046
2048
2047
- builtinProtocol = tc. getProtocol (
2048
- expr->getLoc (),
2049
+ builtinProtocol = TypeChecker:: getProtocol (
2050
+ cs. getASTContext (), expr->getLoc (),
2049
2051
KnownProtocolKind::ExpressibleByBuiltinStringLiteral);
2050
2052
builtinLiteralFuncName
2051
2053
= DeclName (tc.Context , DeclBaseName::createConstructor (),
@@ -2070,9 +2072,10 @@ namespace {
2070
2072
tc.Context .getIdentifier (" utf8CodeUnitCount" ),
2071
2073
tc.Context .getIdentifier (" isASCII" ) });
2072
2074
2073
- builtinProtocol = tc.getProtocol (
2074
- expr->getLoc (),
2075
- KnownProtocolKind::ExpressibleByBuiltinExtendedGraphemeClusterLiteral);
2075
+ builtinProtocol = TypeChecker::getProtocol (
2076
+ cs.getASTContext (), expr->getLoc (),
2077
+ KnownProtocolKind::
2078
+ ExpressibleByBuiltinExtendedGraphemeClusterLiteral);
2076
2079
brokenProtocolDiag =
2077
2080
diag::extended_grapheme_cluster_literal_broken_proto;
2078
2081
brokenBuiltinProtocolDiag =
@@ -2088,8 +2091,8 @@ namespace {
2088
2091
= DeclName (tc.Context , DeclBaseName::createConstructor (),
2089
2092
{tc.Context .Id_builtinUnicodeScalarLiteral });
2090
2093
2091
- builtinProtocol = tc. getProtocol (
2092
- expr->getLoc (),
2094
+ builtinProtocol = TypeChecker:: getProtocol (
2095
+ cs. getASTContext (), expr->getLoc (),
2093
2096
KnownProtocolKind::ExpressibleByBuiltinUnicodeScalarLiteral);
2094
2097
2095
2098
brokenProtocolDiag = diag::unicode_scalar_literal_broken_proto;
@@ -2125,10 +2128,10 @@ namespace {
2125
2128
auto loc = expr->getStartLoc ();
2126
2129
2127
2130
auto fetchProtocolInitWitness =
2128
- [&](KnownProtocolKind protocolKind, Type type,
2129
- ArrayRef<Identifier> argLabels) -> ConcreteDeclRef {
2130
-
2131
- auto proto = tc. getProtocol (loc, protocolKind);
2131
+ [&](KnownProtocolKind protocolKind, Type type,
2132
+ ArrayRef<Identifier> argLabels) -> ConcreteDeclRef {
2133
+ auto proto =
2134
+ TypeChecker:: getProtocol (cs. getASTContext (), loc, protocolKind);
2132
2135
assert (proto && " Missing string interpolation protocol?" );
2133
2136
2134
2137
auto conformance =
@@ -2145,9 +2148,9 @@ namespace {
2145
2148
return witness;
2146
2149
};
2147
2150
2148
- auto *interpolationProto =
2149
- tc. getProtocol ( expr->getLoc (),
2150
- KnownProtocolKind::ExpressibleByStringInterpolation);
2151
+ auto *interpolationProto = TypeChecker::getProtocol (
2152
+ cs. getASTContext (), expr->getLoc (),
2153
+ KnownProtocolKind::ExpressibleByStringInterpolation);
2151
2154
auto associatedTypeDecl = interpolationProto->getAssociatedType (
2152
2155
tc.Context .Id_StringInterpolation );
2153
2156
if (associatedTypeDecl == nullptr ) {
@@ -2235,7 +2238,7 @@ namespace {
2235
2238
}
2236
2239
2237
2240
// Find the appropriate object literal protocol.
2238
- auto proto = tc. getLiteralProtocol (expr);
2241
+ auto proto = TypeChecker:: getLiteralProtocol (cs. getASTContext (), expr);
2239
2242
assert (proto && " Missing object literal protocol?" );
2240
2243
auto conformance =
2241
2244
TypeChecker::conformsToProtocol (conformingType, proto, cs.DC ,
@@ -2494,10 +2497,9 @@ namespace {
2494
2497
auto baseTyNominalDecl = baseTyUnwrapped
2495
2498
->getNominalOrBoundGenericNominal ();
2496
2499
auto &tc = cs.getTypeChecker ();
2497
- auto results = tc.lookupMember (baseTyNominalDecl->getModuleContext (),
2498
- baseTyUnwrapped,
2499
- memberName,
2500
- defaultMemberLookupOptions);
2500
+ auto results = TypeChecker::lookupMember (
2501
+ baseTyNominalDecl->getModuleContext (), baseTyUnwrapped,
2502
+ memberName, defaultMemberLookupOptions);
2501
2503
2502
2504
// Filter out any functions, instance members, enum cases with
2503
2505
// associated values or variables whose type does not match the
@@ -2892,9 +2894,9 @@ namespace {
2892
2894
Type arrayTy = cs.getType (expr);
2893
2895
auto &tc = cs.getTypeChecker ();
2894
2896
2895
- ProtocolDecl *arrayProto
2896
- = tc. getProtocol ( expr->getLoc (),
2897
- KnownProtocolKind::ExpressibleByArrayLiteral);
2897
+ ProtocolDecl *arrayProto = TypeChecker::getProtocol (
2898
+ cs. getASTContext (), expr->getLoc (),
2899
+ KnownProtocolKind::ExpressibleByArrayLiteral);
2898
2900
assert (arrayProto && " type-checked array literal w/o protocol?!" );
2899
2901
2900
2902
auto conformance =
@@ -2938,9 +2940,9 @@ namespace {
2938
2940
Type dictionaryTy = cs.getType (expr);
2939
2941
2940
2942
auto &tc = cs.getTypeChecker ();
2941
- ProtocolDecl *dictionaryProto
2942
- = tc. getProtocol ( expr->getLoc (),
2943
- KnownProtocolKind::ExpressibleByDictionaryLiteral);
2943
+ ProtocolDecl *dictionaryProto = TypeChecker::getProtocol (
2944
+ cs. getASTContext (), expr->getLoc (),
2945
+ KnownProtocolKind::ExpressibleByDictionaryLiteral);
2944
2946
2945
2947
auto conformance =
2946
2948
TypeChecker::conformsToProtocol (dictionaryTy, dictionaryProto, cs.DC ,
@@ -4585,7 +4587,7 @@ namespace {
4585
4587
auto dc = subscript->getInnermostDeclContext ();
4586
4588
4587
4589
auto indexType = AnyFunctionType::composeInput (
4588
- cs.TC . Context ,
4590
+ cs.getASTContext () ,
4589
4591
subscript->getInterfaceType ()->castTo <AnyFunctionType>()->getParams (),
4590
4592
/* canonicalVararg=*/ false );
4591
4593
@@ -6773,8 +6775,8 @@ ExprRewriter::finishApplyDynamicCallable(ApplyExpr *apply,
6773
6775
auto dictLitProto =
6774
6776
ctx.getProtocol (KnownProtocolKind::ExpressibleByDictionaryLiteral);
6775
6777
auto conformance =
6776
- cs. TC . conformsToProtocol (argumentType, dictLitProto, cs.DC ,
6777
- ConformanceCheckFlags::InExpression);
6778
+ TypeChecker:: conformsToProtocol (argumentType, dictLitProto, cs.DC ,
6779
+ ConformanceCheckFlags::InExpression);
6778
6780
auto keyType = conformance.getTypeWitnessByName (argumentType, ctx.Id_Key );
6779
6781
auto valueType =
6780
6782
conformance.getTypeWitnessByName (argumentType, ctx.Id_Value );
@@ -6827,7 +6829,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, ConcreteDeclRef callee,
6827
6829
= [&](ApplyExpr *apply,
6828
6830
ConcreteDeclRef declRef,
6829
6831
Type openedType) -> Expr* {
6830
- switch (cs. TC . getDeclTypeCheckingSemantics (declRef.getDecl ())) {
6832
+ switch (TypeChecker:: getDeclTypeCheckingSemantics (declRef.getDecl ())) {
6831
6833
case DeclTypeCheckingSemantics::TypeOf: {
6832
6834
// Resolve into a DynamicTypeExpr.
6833
6835
auto arg = apply->getArg ();
0 commit comments