diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index 794f5801bf2ba..f1b4356dd9786 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -5666,9 +5666,10 @@ class VarDecl : public AbstractStorageDecl { return hasName() ? getBaseIdentifier().str() : "_"; } - /// Get the type of the variable within its context. If the context is generic, - /// this will use archetypes. - Type getType() const; + /// Maps the interface type of the variable declaration into the generic + /// environment of its parent DeclContext. Make sure this is what you want + /// and not just getInterfaceType(). + Type getTypeInContext() const; /// Retrieve the source range of the variable type, or an invalid range if the /// variable's type is not explicitly written in the source. diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 32973c9f5c4be..9e15816a4107b 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -701,15 +701,6 @@ namespace { if (auto *MD = dyn_cast(VD)) printGenericParameters(OS, MD->getParsedGenericParams()); - if (auto *var = dyn_cast(VD)) { - PrintWithColorRAII(OS, TypeColor) << " type='"; - if (var->hasInterfaceType()) - var->getType().print(PrintWithColorRAII(OS, TypeColor).getOS()); - else - PrintWithColorRAII(OS, TypeColor) << ""; - PrintWithColorRAII(OS, TypeColor) << "'"; - } - if (VD->hasInterfaceType()) { PrintWithColorRAII(OS, InterfaceTypeColor) << " interface type='"; VD->getInterfaceType()->print( @@ -1004,10 +995,6 @@ namespace { << " apiName=" << P->getArgumentName(); if (P->hasInterfaceType()) { - PrintWithColorRAII(OS, TypeColor) << " type='"; - P->getType().print(PrintWithColorRAII(OS, TypeColor).getOS()); - PrintWithColorRAII(OS, TypeColor) << "'"; - PrintWithColorRAII(OS, InterfaceTypeColor) << " interface type='"; P->getInterfaceType().print( PrintWithColorRAII(OS, InterfaceTypeColor).getOS()); diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 72168b6a28080..263268cefdaff 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -5484,7 +5484,7 @@ NominalTypeDecl::getExecutorLegacyOwnedEnqueueFunction() const { if ((params->get(0)->getSpecifier() == ParamSpecifier::LegacyOwned || params->get(0)->getSpecifier() == ParamSpecifier::Consuming) && - params->get(0)->getType()->isEqual(legacyJobDecl->getDeclaredInterfaceType())) { + params->get(0)->getInterfaceType()->isEqual(legacyJobDecl->getDeclaredInterfaceType())) { return funcDecl; } } @@ -6820,7 +6820,7 @@ VarDecl::VarDecl(DeclKind kind, bool isStatic, VarDecl::Introducer introducer, Bits.VarDecl.IsTopLevelGlobal = false; } -Type VarDecl::getType() const { +Type VarDecl::getTypeInContext() const { return getDeclContext()->mapTypeIntoContext(getInterfaceType()); } @@ -7387,7 +7387,7 @@ LifetimeAnnotation ParamDecl::getLifetimeAnnotation() const { auto specifier = getSpecifier(); // Copyable parameters which are consumed have eager-move semantics. if (specifier == ParamDecl::Specifier::Consuming && - !getType()->isPureMoveOnly()) { + !getTypeInContext()->isPureMoveOnly()) { if (getAttrs().hasAttribute()) return LifetimeAnnotation::Lexical; return LifetimeAnnotation::EagerMove; @@ -8637,10 +8637,10 @@ AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const { } static bool isPotentialCompletionHandler(const ParamDecl *param) { - if (!param->getType()) + if (!param->getInterfaceType()) return false; - const AnyFunctionType *paramType = param->getType()->getAs(); + auto *paramType = param->getInterfaceType()->getAs(); return paramType && paramType->getResult()->isVoid() && !paramType->isNoEscape() && !param->isAutoClosure(); } @@ -8710,11 +8710,11 @@ AbstractFunctionDecl::findPotentialCompletionHandlerParam( } // Don't have types for some reason, just return no match - if (!param->getType() || !asyncParam->getType()) + if (!param->getInterfaceType() || !asyncParam->getInterfaceType()) return llvm::None; - paramMatches = param->getType()->matchesParameter(asyncParam->getType(), - TypeMatchOptions()); + paramMatches = param->getInterfaceType()->matchesParameter( + asyncParam->getInterfaceType(), TypeMatchOptions()); } if (paramMatches) { @@ -9618,7 +9618,7 @@ LifetimeAnnotation FuncDecl::getLifetimeAnnotation() const { // Copyable parameters which are consumed have eager-move semantics. if (getSelfAccessKind() == SelfAccessKind::Consuming) { auto *selfDecl = getImplicitSelfDecl(); - if (selfDecl && !selfDecl->getType()->isPureMoveOnly()) { + if (selfDecl && !selfDecl->getTypeInContext()->isPureMoveOnly()) { if (getAttrs().hasAttribute()) return LifetimeAnnotation::Lexical; return LifetimeAnnotation::EagerMove; @@ -10047,7 +10047,7 @@ Type TypeBase::getSwiftNewtypeUnderlyingType() { for (auto member : structDecl->getMembers()) if (auto varDecl = dyn_cast(member)) if (varDecl->getName() == getASTContext().Id_rawValue) - return varDecl->getType(); + return varDecl->getInterfaceType(); return {}; } diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 6762babe0ff48..3f16c42a1b98f 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1887,7 +1887,7 @@ ActorIsolation ClosureActorIsolation::getActorIsolation() const { case ClosureActorIsolation::ActorInstance: { auto selfDecl = getActorInstance(); auto actor = - selfDecl->getType()->getReferenceStorageReferent()->getAnyActor(); + selfDecl->getTypeInContext()->getReferenceStorageReferent()->getAnyActor(); assert(actor && "Bad closure actor isolation?"); // FIXME: This could be a parameter... or a capture... hmmm. return ActorIsolation::forActorInstanceSelf(actor).withPreconcurrency( diff --git a/lib/ClangImporter/ClangDerivedConformances.cpp b/lib/ClangImporter/ClangDerivedConformances.cpp index 3b0bc2ee86b5f..0c2038afcc590 100644 --- a/lib/ClangImporter/ClangDerivedConformances.cpp +++ b/lib/ClangImporter/ClangDerivedConformances.cpp @@ -101,7 +101,7 @@ static FuncDecl *getInsertFunc(NominalTypeDecl *decl, if (params->size() != 1) continue; auto param = params->front(); - if (param->getType()->getCanonicalType() != + if (param->getTypeInContext()->getCanonicalType() != valueType->getUnderlyingType()->getCanonicalType()) continue; insert = candidateMethod; @@ -167,8 +167,8 @@ static ValueDecl *getEqualEqualOperator(NominalTypeDecl *decl) { auto rhs = params->get(1); if (lhs->isInOut() || rhs->isInOut()) return false; - auto lhsTy = lhs->getType(); - auto rhsTy = rhs->getType(); + auto lhsTy = lhs->getTypeInContext(); + auto rhsTy = rhs->getTypeInContext(); if (!lhsTy || !rhsTy) return false; auto lhsNominal = lhsTy->getAnyNominal(); @@ -197,8 +197,8 @@ static FuncDecl *getMinusOperator(NominalTypeDecl *decl) { auto rhs = params->get(1); if (lhs->isInOut() || rhs->isInOut()) return false; - auto lhsTy = lhs->getType(); - auto rhsTy = rhs->getType(); + auto lhsTy = lhs->getTypeInContext(); + auto rhsTy = rhs->getTypeInContext(); if (!lhsTy || !rhsTy) return false; auto lhsNominal = lhsTy->getAnyNominal(); @@ -230,8 +230,8 @@ static FuncDecl *getPlusEqualOperator(NominalTypeDecl *decl, Type distanceTy) { auto rhs = params->get(1); if (rhs->isInOut()) return false; - auto lhsTy = lhs->getType(); - auto rhsTy = rhs->getType(); + auto lhsTy = lhs->getTypeInContext(); + auto rhsTy = rhs->getTypeInContext(); if (!lhsTy || !rhsTy) return false; if (rhsTy->getCanonicalType() != distanceTy->getCanonicalType()) @@ -454,7 +454,7 @@ void swift::conformToCxxIteratorIfNeeded( // Check if present: `var pointee: Pointee { get }` auto pointeeId = ctx.getIdentifier("pointee"); auto pointee = lookupDirectSingleWithoutExtensions(decl, pointeeId); - if (!pointee || pointee->isGetterMutating() || pointee->getType()->hasError()) + if (!pointee || pointee->isGetterMutating() || pointee->getTypeInContext()->hasError()) return; // Check if `var pointee: Pointee` is settable. This is required for the @@ -498,7 +498,7 @@ void swift::conformToCxxIteratorIfNeeded( return; impl.addSynthesizedTypealias(decl, ctx.getIdentifier("Pointee"), - pointee->getType()); + pointee->getTypeInContext()); if (pointeeSettable) impl.addSynthesizedProtocolAttrs( decl, {KnownProtocolKind::UnsafeCxxMutableInputIterator}); diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 86c8d73e0f7f4..aee850142f84b 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -4779,7 +4779,7 @@ synthesizeBaseClassMethodBody(AbstractFunctionDecl *afd, void *context) { for (auto param : *funcDecl->getParameters()) { auto paramRefExpr = new (ctx) DeclRefExpr(param, DeclNameLoc(), /*Implicit=*/true); - paramRefExpr->setType(param->getType()); + paramRefExpr->setType(param->getTypeInContext()); forwardingParams.push_back(paramRefExpr); } @@ -4791,7 +4791,7 @@ synthesizeBaseClassMethodBody(AbstractFunctionDecl *afd, void *context) { auto *selfDecl = funcDecl->getImplicitSelfDecl(); auto selfExpr = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true); - selfExpr->setType(selfDecl->getType()); + selfExpr->setType(selfDecl->getTypeInContext()); auto staticCastRefExpr = getInteropStaticCastDeclRefExpr( ctx, baseStruct->getClangDecl()->getOwningModule(), baseType, @@ -4845,7 +4845,7 @@ synthesizeBaseClassFieldGetterBody(AbstractFunctionDecl *afd, void *context) { auto selfDecl = getterDecl->getImplicitSelfDecl(); auto selfExpr = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true); - selfExpr->setType(selfDecl->getType()); + selfExpr->setType(selfDecl->getTypeInContext()); auto staticCastRefExpr = getInteropStaticCastDeclRefExpr( ctx, baseStruct->getClangDecl()->getOwningModule(), @@ -4863,7 +4863,7 @@ synthesizeBaseClassFieldGetterBody(AbstractFunctionDecl *afd, void *context) { auto paramRefExpr = new (ctx) DeclRefExpr(paramDecl, DeclNameLoc(), /*Implicit=*/ true); - paramRefExpr->setType(paramDecl->getType()); + paramRefExpr->setType(paramDecl->getTypeInContext()); auto *argList = ArgumentList::forImplicitUnlabeled(ctx, {paramRefExpr}); baseMember = SubscriptExpr::create(ctx, casted, argList, subscript); @@ -4878,7 +4878,7 @@ synthesizeBaseClassFieldGetterBody(AbstractFunctionDecl *afd, void *context) { baseMember = new (ctx) MemberRefExpr(casted, SourceLoc(), baseClassVar, DeclNameLoc(), /*Implicit=*/true, accessKind); - baseMember->setType(cast(baseClassVar)->getType()); + baseMember->setType(cast(baseClassVar)->getTypeInContext()); } auto ret = new (ctx) ReturnStmt(SourceLoc(), baseMember); @@ -4914,7 +4914,7 @@ synthesizeBaseClassFieldSetterBody(AbstractFunctionDecl *afd, void *context) { auto paramRefExpr = new (ctx) DeclRefExpr(paramDecl, DeclNameLoc(), /*Implicit=*/ true); - paramRefExpr->setType(paramDecl->getType()); + paramRefExpr->setType(paramDecl->getTypeInContext()); auto *argList = ArgumentList::forImplicitUnlabeled(ctx, {paramRefExpr}); storedRef = SubscriptExpr::create(ctx, pointeePropertyRefExpr, argList, subscript); @@ -4930,13 +4930,13 @@ synthesizeBaseClassFieldSetterBody(AbstractFunctionDecl *afd, void *context) { storedRef = new (ctx) MemberRefExpr(pointeePropertyRefExpr, SourceLoc(), baseClassVar, DeclNameLoc(), /*Implicit=*/true, accessKind); - storedRef->setType(LValueType::get(cast(baseClassVar)->getType())); + storedRef->setType(LValueType::get(cast(baseClassVar)->getTypeInContext())); } auto newValueParamRefExpr = new (ctx) DeclRefExpr(setterDecl->getParameters()->get(0), DeclNameLoc(), /*Implicit=*/true); - newValueParamRefExpr->setType(setterDecl->getParameters()->get(0)->getType()); + newValueParamRefExpr->setType(setterDecl->getParameters()->get(0)->getTypeInContext()); auto assignExpr = new (ctx) AssignExpr(storedRef, SourceLoc(), newValueParamRefExpr, @@ -5998,14 +5998,15 @@ synthesizeDependentTypeThunkParamForwarding(AbstractFunctionDecl *afd, void *con SmallVector forwardingParams; unsigned paramIndex = 0; for (auto param : *thunkDecl->getParameters()) { - if (isa(param->getType().getPointer())) { + if (isa(param->getInterfaceType().getPointer())) { paramIndex++; continue; } - auto paramTy = param->getType(); + auto paramTy = param->getTypeInContext(); auto isInOut = param->isInOut(); auto specParamTy = - specializedFuncDecl->getParameters()->get(paramIndex)->getType(); + specializedFuncDecl->getParameters()->get(paramIndex) + ->getTypeInContext(); Expr *paramRefExpr = new (ctx) DeclRefExpr(param, DeclNameLoc(), /*Implicit=*/true); @@ -6059,7 +6060,8 @@ synthesizeDependentTypeThunkParamForwarding(AbstractFunctionDecl *afd, void *con specializedFuncCallExpr->setThrows(false); Expr *resultExpr = nullptr; - if (specializedFuncCallExpr->getType()->isEqual(thunkDecl->getResultInterfaceType())) { + if (specializedFuncCallExpr->getType()->isEqual( + thunkDecl->getResultInterfaceType())) { resultExpr = specializedFuncCallExpr; } else { resultExpr = ForcedCheckedCastExpr::createImplicit( @@ -6085,7 +6087,7 @@ static ValueDecl *addThunkForDependentTypes(FuncDecl *oldDecl, for (auto *newFnParam : *newDecl->getParameters()) { // If the un-specialized function had a parameter with type "Any" preserve // that parameter. Otherwise, use the new function parameter. - auto oldParamType = oldDecl->getParameters()->get(parameterIndex)->getType(); + auto oldParamType = oldDecl->getParameters()->get(parameterIndex)->getInterfaceType(); if (oldParamType->isEqual(newDecl->getASTContext().getAnyExistentialType())) { updatedAnyParams = true; auto newParam = @@ -6144,10 +6146,10 @@ synthesizeForwardingThunkBody(AbstractFunctionDecl *afd, void *context) { SmallVector forwardingParams; for (auto param : *thunkDecl->getParameters()) { - if (isa(param->getType().getPointer())) { + if (isa(param->getInterfaceType().getPointer())) { continue; } - auto paramTy = param->getType(); + auto paramTy = param->getTypeInContext(); auto isInOut = param->isInOut(); Expr *paramRefExpr = new (ctx) DeclRefExpr(param, DeclNameLoc(), diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index f2a1779d462c2..a45f929ace1d4 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -2492,7 +2492,7 @@ namespace { // If we have a getter and a setter make sure the types line up. if (setter && !getter->getResultInterfaceType()->isEqual( - setter->getParameters()->get(0)->getType())) + setter->getParameters()->get(0)->getTypeInContext())) continue; // If the name that we would import this as already exists, then don't @@ -3528,7 +3528,7 @@ namespace { assert(func->getParameters()->size() == 1); auto typeDecl = dc->getSelfNominalTypeDecl(); auto parameter = func->getParameters()->get(0); - auto parameterType = parameter->getType(); + auto parameterType = parameter->getTypeInContext(); if (!typeDecl || !parameterType) return nullptr; if (parameter->isInOut()) @@ -6913,7 +6913,8 @@ SwiftDeclConverter::importSubscript(Decl *decl, // Make sure that the index types are equivalent. // FIXME: Rectify these the same way we do for element types. - if (!setterIndex->getType()->isEqual(getterIndex->getType())) { + if (!setterIndex->getInterfaceType()->isEqual( + getterIndex->getInterfaceType())) { // If there is an existing subscript operation, we're done. if (existingSubscript) return decl == getter ? existingSubscript : nullptr; diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index 863175b4f0d18..93791b8044905 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -1,4 +1,4 @@ -//===--- DeclSynthesizer.h - Synthesize helper Swift decls ----------------===// +//===--- DeclSynthesizer.cpp - Synthesize helper Swift decls --------------===// // // This source file is part of the Swift.org open source project // @@ -72,7 +72,7 @@ static DeclRefExpr *createParamRefExpr(AccessorDecl *accessorDecl, auto paramDecl = accessorDecl->getParameters()->get(index); auto paramRefExpr = new (ctx) DeclRefExpr(paramDecl, DeclNameLoc(), /*Implicit*/ true); - paramRefExpr->setType(paramDecl->getType()); + paramRefExpr->setType(paramDecl->getTypeInContext()); return paramRefExpr; } @@ -161,7 +161,7 @@ SwiftDeclSynthesizer::createVarWithPattern(DeclContext *dc, Identifier name, Pattern *SwiftDeclSynthesizer::createTypedNamedPattern(VarDecl *decl) { ASTContext &Ctx = decl->getASTContext(); - Type ty = decl->getType(); + Type ty = decl->getTypeInContext(); Pattern *P = new (Ctx) NamedPattern(decl); P->setType(ty); @@ -538,19 +538,19 @@ synthesizeValueConstructorBody(AbstractFunctionDecl *afd, void *context) { // Construct left-hand side. Expr *lhs = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*Implicit=*/true); - lhs->setType(LValueType::get(selfDecl->getType())); + lhs->setType(LValueType::get(selfDecl->getTypeInContext())); auto semantics = (var->hasStorage() ? AccessSemantics::DirectToStorage : AccessSemantics::Ordinary); lhs = new (ctx) MemberRefExpr(lhs, SourceLoc(), var, DeclNameLoc(), /*Implicit=*/true, semantics); - lhs->setType(LValueType::get(var->getType())); + lhs->setType(LValueType::get(var->getTypeInContext())); // Construct right-hand side. auto rhs = new (ctx) DeclRefExpr(parameters->get(paramPos), DeclNameLoc(), /*Implicit=*/true); - rhs->setType(parameters->get(paramPos)->getType()); + rhs->setType(parameters->get(paramPos)->getTypeInContext()); // Add assignment. auto assign = new (ctx) AssignExpr(lhs, SourceLoc(), rhs, @@ -658,7 +658,7 @@ synthesizeRawValueBridgingConstructorBody(AbstractFunctionDecl *afd, // Construct left-hand side. Expr *lhs = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*Implicit=*/true); - lhs->setType(LValueType::get(selfDecl->getType())); + lhs->setType(LValueType::get(selfDecl->getTypeInContext())); lhs = new (ctx) MemberRefExpr(lhs, SourceLoc(), storedRawValue, DeclNameLoc(), @@ -670,10 +670,10 @@ synthesizeRawValueBridgingConstructorBody(AbstractFunctionDecl *afd, auto *paramDecl = init->getParameters()->get(0); auto *paramRef = new (ctx) DeclRefExpr(paramDecl, DeclNameLoc(), /*Implicit=*/true); - paramRef->setType(paramDecl->getType()); + paramRef->setType(paramDecl->getTypeInContext()); Expr *rhs = paramRef; - if (!storedRawValue->getInterfaceType()->isEqual(paramDecl->getType())) { + if (!storedRawValue->getInterfaceType()->isEqual(paramDecl->getInterfaceType())) { auto bridge = new (ctx) BridgeToObjCExpr(paramRef, storedType); bridge->setType(storedType); @@ -1207,12 +1207,12 @@ synthesizeEnumRawValueConstructorBody(AbstractFunctionDecl *afd, auto selfDecl = ctorDecl->getImplicitSelfDecl(); auto selfRef = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true); - selfRef->setType(LValueType::get(selfDecl->getType())); + selfRef->setType(LValueType::get(selfDecl->getTypeInContext())); auto param = ctorDecl->getParameters()->get(0); auto paramRef = new (ctx) DeclRefExpr(param, DeclNameLoc(), /*implicit*/ true); - paramRef->setType(param->getType()); + paramRef->setType(param->getTypeInContext()); auto reinterpretCast = cast( getBuiltinValueDecl(ctx, ctx.getIdentifier("reinterpretCast"))); @@ -1284,7 +1284,7 @@ synthesizeEnumRawValueGetterBody(AbstractFunctionDecl *afd, void *context) { auto *selfDecl = getterDecl->getImplicitSelfDecl(); auto selfRef = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true); - selfRef->setType(selfDecl->getType()); + selfRef->setType(selfDecl->getTypeInContext()); auto reinterpretCast = cast( getBuiltinValueDecl(ctx, ctx.getIdentifier("reinterpretCast"))); @@ -1357,7 +1357,7 @@ synthesizeStructRawValueGetterBody(AbstractFunctionDecl *afd, void *context) { auto *selfDecl = getterDecl->getImplicitSelfDecl(); auto selfRef = new (ctx) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true); - selfRef->setType(selfDecl->getType()); + selfRef->setType(selfDecl->getTypeInContext()); auto storedType = storedVar->getInterfaceType(); auto storedRef = new (ctx) @@ -1853,7 +1853,7 @@ synthesizeOperatorMethodBody(AbstractFunctionDecl *afd, void *context) { itr != funcDecl->getParameters()->end(); itr++) { auto param = *itr; auto isInOut = param->isInOut(); - auto paramTy = param->getType(); + auto paramTy = param->getTypeInContext(); Expr *paramRefExpr = new (ctx) DeclRefExpr(param, DeclNameLoc(), /*Implicit*/ true); paramRefExpr->setType(isInOut ? LValueType::get(paramTy) : paramTy); @@ -1869,7 +1869,7 @@ synthesizeOperatorMethodBody(AbstractFunctionDecl *afd, void *context) { // Lhs parameter auto baseParam = funcDecl->getParameters()->front(); - auto baseParamTy = baseParam->getType(); + auto baseParamTy = baseParam->getTypeInContext(); auto baseIsInOut = baseParam->isInOut(); Expr *baseExpr = diff --git a/lib/ConstExtract/ConstExtract.cpp b/lib/ConstExtract/ConstExtract.cpp index 9545db2e6c636..8122a41e4d501 100644 --- a/lib/ConstExtract/ConstExtract.cpp +++ b/lib/ConstExtract/ConstExtract.cpp @@ -452,7 +452,7 @@ extractEnumCases(NominalTypeDecl *Decl) { : llvm::Optional( Parameter->getParameterName().str().str()); - Parameters.push_back({Label, Parameter->getType()}); + Parameters.push_back({Label, Parameter->getInterfaceType()}); } } @@ -883,7 +883,8 @@ void writeProperties(llvm::json::OStream &JSON, JSON.object([&] { const auto *decl = PropertyInfo.VarDecl; JSON.attribute("label", decl->getName().str().str()); - JSON.attribute("type", toFullyQualifiedTypeNameString(decl->getType())); + JSON.attribute("type", toFullyQualifiedTypeNameString( + decl->getInterfaceType())); JSON.attribute("mangledTypeName", "n/a - deprecated"); JSON.attribute("isStatic", decl->isStatic() ? "true" : "false"); JSON.attribute("isComputed", !decl->hasStorage() ? "true" : "false"); diff --git a/lib/IDE/ArgumentCompletion.cpp b/lib/IDE/ArgumentCompletion.cpp index e8ceaaf5031b2..e0c7169bdbbe5 100644 --- a/lib/IDE/ArgumentCompletion.cpp +++ b/lib/IDE/ArgumentCompletion.cpp @@ -249,7 +249,7 @@ void ArgumentTypeCheckCompletionCallback::sawSolutionImpl(const Solution &S) { } else if (const ParamDecl *DeclParam = getParameterAt(Info.ValueRef, Idx)) { Optional |= DeclParam->isDefaultArgument(); - Optional |= DeclParam->getType()->is(); + Optional |= DeclParam->getInterfaceType()->is(); } } const AnyFunctionType::Param *TypeParam = &ParamsToPass[Idx]; diff --git a/lib/IDE/IDETypeChecking.cpp b/lib/IDE/IDETypeChecking.cpp index 8823514c52f7d..0ff2bc7f5fd5b 100644 --- a/lib/IDE/IDETypeChecking.cpp +++ b/lib/IDE/IDETypeChecking.cpp @@ -855,7 +855,7 @@ class VariableTypeCollector : public SourceEntityWalker { PrintOptions Options; Options.SynthesizeSugarOnTypes = true; Options.FullyQualifiedTypes = FullyQualified; - auto Ty = VD->getType(); + auto Ty = VD->getInterfaceType(); // Skip this declaration and its children if the type is an error type. if (Ty->is()) { return false; diff --git a/lib/IRGen/DebugTypeInfo.cpp b/lib/IRGen/DebugTypeInfo.cpp index 3965cd0effcbc..cd1edd3fef885 100644 --- a/lib/IRGen/DebugTypeInfo.cpp +++ b/lib/IRGen/DebugTypeInfo.cpp @@ -120,7 +120,7 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV, auto LowTy = GV->getLoweredType().getASTType(); auto *Type = LowTy.getPointer(); if (auto *Decl = GV->getDecl()) { - auto DeclType = Decl->getType(); + auto DeclType = Decl->getTypeInContext(); if (DeclType->isEqual(LowTy)) Type = DeclType.getPointer(); } @@ -141,7 +141,7 @@ DebugTypeInfo::getGlobalFixedBuffer(SILGlobalVariable *GV, auto LowTy = GV->getLoweredType().getASTType(); auto *Type = LowTy.getPointer(); if (auto *Decl = GV->getDecl()) { - auto DeclType = Decl->getType(); + auto DeclType = Decl->getTypeInContext(); if (DeclType->isEqual(LowTy)) Type = DeclType.getPointer(); } diff --git a/lib/IRGen/IRABIDetailsProvider.cpp b/lib/IRGen/IRABIDetailsProvider.cpp index a20ea6912c157..d00516614bdba 100644 --- a/lib/IRGen/IRABIDetailsProvider.cpp +++ b/lib/IRGen/IRABIDetailsProvider.cpp @@ -149,7 +149,7 @@ class IRABIDetailsProviderImpl { llvm::SmallVector silParamMapping; for (auto param : *fd->getParameters()) { if (auto *tuple = - param->getType()->getDesugaredType()->getAs()) { + param->getInterfaceType()->getAs()) { if (tuple->getNumElements() > 0) return llvm::None; } diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index f4e5c146a6eff..f4eeb22e9b791 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -5660,9 +5660,9 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) { return; if (Decl) { - Type Desugared = Decl->getType()->getDesugaredType(); - if (Desugared->getClassOrBoundGenericClass() || - Desugared->getStructOrBoundGenericStruct()) + Type Ty = Decl->getTypeInContext(); + if (Ty->getClassOrBoundGenericClass() || + Ty->getStructOrBoundGenericStruct()) zeroInit(dyn_cast(addr.getAddress())); } emitDebugInfoForAllocStack(i, type, addr.getAddress()); diff --git a/lib/Index/Index.cpp b/lib/Index/Index.cpp index b1a5b1cc6f2a6..e07abe3b6f891 100644 --- a/lib/Index/Index.cpp +++ b/lib/Index/Index.cpp @@ -1809,7 +1809,7 @@ bool IndexSwiftASTWalker::initFuncDeclIndexSymbol(FuncDecl *D, } if (senderParam) - if (auto nominal = senderParam->getType()->getAnyNominal()) + if (auto nominal = senderParam->getInterfaceType()->getAnyNominal()) addRelation(Info, (SymbolRoleSet) SymbolRole::RelationIBTypeOf, nominal); } diff --git a/lib/Refactoring/Refactoring.cpp b/lib/Refactoring/Refactoring.cpp index 7baad98c5aee7..7a116e688fafc 100644 --- a/lib/Refactoring/Refactoring.cpp +++ b/lib/Refactoring/Refactoring.cpp @@ -3442,7 +3442,7 @@ collectMembersForInit(ResolvedCursorInfoPtr CursorInfo, auto NameRange = Lexer::getCharSourceRangeFromSourceRange(SM, varDecl->getNameLoc()); - memberVector.emplace_back(NameRange, varDecl->getType(), defaultInit); + memberVector.emplace_back(NameRange, varDecl->getTypeInContext(), defaultInit); } return targetLocation; @@ -4230,7 +4230,7 @@ bool RefactoringActionConvertToComputedProperty::performChange() { // Get type auto SV = Binding->getSingleVar(); - auto SVType = SV->getType(); + auto SVType = SV->getTypeInContext(); auto TR = SV->getTypeReprOrParentPatternTypeRepr(); SmallString<64> DeclBuffer; @@ -4516,7 +4516,7 @@ struct AsyncHandlerDesc { /// Get the type of the completion handler. swift::Type getType() const { if (auto Var = Handler.dyn_cast()) { - return Var->getType(); + return Var->getTypeInContext(); } else if (auto Func = Handler.dyn_cast()) { auto Type = Func->getInterfaceType(); // Undo the self curry thunk if we are referencing a member function. @@ -5365,7 +5365,7 @@ class ClosureCallbackParams final { return false; if (getResultParam() == Param) return true; - return HandlerDesc.shouldUnwrap(Param->getType()); + return HandlerDesc.shouldUnwrap(Param->getTypeInContext()); } /// Whether \p Param is the known Bool parameter that indicates success or @@ -7174,7 +7174,7 @@ class AsyncConverter : private SourceEntityWalker { void addFallbackVars(ArrayRef FallbackParams, const ClosureCallbackParams &AllParams) { for (auto *Param : FallbackParams) { - auto Ty = Param->getType(); + auto Ty = Param->getTypeInContext(); auto ParamName = newNameFor(Param); // If this is the known bool success param, we can use 'let' and type it @@ -8060,7 +8060,7 @@ class AsyncConverter : private SourceEntityWalker { llvm_unreachable("Already handled"); case BlockKind::ERROR: if (ErrParam) { - if (HandlerDesc.shouldUnwrap(ErrParam->getType())) { + if (HandlerDesc.shouldUnwrap(ErrParam->getTypeInContext())) { Placeholders.insert(ErrParam); Unwraps.insert(ErrParam); } @@ -8070,7 +8070,7 @@ class AsyncConverter : private SourceEntityWalker { break; case BlockKind::SUCCESS: for (auto *SuccessParam : SuccessParams) { - auto Ty = SuccessParam->getType(); + auto Ty = SuccessParam->getTypeInContext(); if (HandlerDesc.shouldUnwrap(Ty)) { // Either unwrap or replace with a placeholder if there's some other // reference diff --git a/lib/SIL/IR/SILConstants.cpp b/lib/SIL/IR/SILConstants.cpp index a91039c2a44e6..f37c04e1020f0 100644 --- a/lib/SIL/IR/SILConstants.cpp +++ b/lib/SIL/IR/SILConstants.cpp @@ -1137,7 +1137,7 @@ static SymbolicValue getIndexedElement(SymbolicValue aggregate, } else { elt = aggregate.getAggregateMembers()[elementNo]; if (auto *decl = type->getStructOrBoundGenericStruct()) { - eltType = decl->getStoredProperties()[elementNo]->getType(); + eltType = decl->getStoredProperties()[elementNo]->getTypeInContext(); } else if (auto tuple = type->getAs()) { assert(elementNo < tuple->getNumElements() && "invalid index"); eltType = tuple->getElement(elementNo).getType(); @@ -1213,7 +1213,7 @@ static SymbolicValue setIndexedElement(SymbolicValue aggregate, } else { oldElts = aggregate.getAggregateMembers(); if (auto *decl = type->getStructOrBoundGenericStruct()) { - eltType = decl->getStoredProperties()[elementNo]->getType(); + eltType = decl->getStoredProperties()[elementNo]->getTypeInContext(); } else if (auto tuple = type->getAs()) { assert(elementNo < tuple->getNumElements() && "invalid index"); eltType = tuple->getElement(elementNo).getType(); diff --git a/lib/SIL/IR/SILFunctionBuilder.cpp b/lib/SIL/IR/SILFunctionBuilder.cpp index f03194ba9dec1..5ee0c0c941246 100644 --- a/lib/SIL/IR/SILFunctionBuilder.cpp +++ b/lib/SIL/IR/SILFunctionBuilder.cpp @@ -129,7 +129,7 @@ void SILFunctionBuilder::addFunctionAttributes( // Give up on tuples. Their elements are added as individual // arguments. It destroys the 1-1 relation ship between parameters // and arguments. - if (isa(CanType(pd->getType()))) + if (pd->getInterfaceType()->is()) break; // First try the "local" parameter name. If there is none, use the // API name. E.g. `foo(apiName localName: Type) {}` diff --git a/lib/SIL/IR/TypeLowering.cpp b/lib/SIL/IR/TypeLowering.cpp index 7a6d31c6ffb87..5fc07fc12a6a2 100644 --- a/lib/SIL/IR/TypeLowering.cpp +++ b/lib/SIL/IR/TypeLowering.cpp @@ -117,7 +117,7 @@ CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture, "should not have attempted to directly capture this variable"); auto &lowering = getTypeLowering( - var->getType(), TypeExpansionContext::noOpaqueTypeArchetypesSubstitution( + var->getTypeInContext(), TypeExpansionContext::noOpaqueTypeArchetypesSubstitution( expansion.getResilienceExpansion())); // If this is a noncopyable 'let' constant that is not a shared paramdecl or @@ -149,14 +149,14 @@ CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture, // have the same lifetime as the closure itself, so we must capture // the box itself and not the payload, even if the closure is noescape, // otherwise they will be destroyed when the closure is formed. - if (var->getType()->is()) { + if (var->getInterfaceType()->is()) { return CaptureKind::Box; } // For 'let' constants if (!var->supportsMutation()) { assert(getTypeLowering( - var->getType(), + var->getTypeInContext(), TypeExpansionContext::noOpaqueTypeArchetypesSubstitution( expansion.getResilienceExpansion())) .isAddressOnly()); @@ -3939,7 +3939,7 @@ TypeConverter::getLoweredLocalCaptures(SILDeclRef fn) { continue; // We can always capture the storage in these cases. - Type captureType = capturedVar->getType()->getMetatypeInstanceType(); + Type captureType = capturedVar->getTypeInContext()->getMetatypeInstanceType(); if (auto *selfType = captureType->getAs()) { captureType = selfType->getSelfType(); diff --git a/lib/SIL/Parser/ParseSIL.cpp b/lib/SIL/Parser/ParseSIL.cpp index 1387625908d59..5affd663cd93f 100644 --- a/lib/SIL/Parser/ParseSIL.cpp +++ b/lib/SIL/Parser/ParseSIL.cpp @@ -7385,7 +7385,7 @@ static llvm::Optional lookupGlobalDecl(Identifier GlobalName, // doesn't matter which declaration we use). for (ValueDecl *ValDecl : CurModuleResults) { auto *VD = cast(ValDecl); - CanType DeclTy = VD->getType()->getCanonicalType(); + CanType DeclTy = VD->getTypeInContext()->getCanonicalType(); if (DeclTy == GlobalType.getASTType() && getDeclSILLinkage(VD) == GlobalLinkage) { return VD; diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp index 556355648cb7a..3072304e5f587 100644 --- a/lib/SILGen/SILGen.cpp +++ b/lib/SILGen/SILGen.cpp @@ -1522,7 +1522,8 @@ bool SILGenModule::hasNonTrivialIVars(ClassDecl *cd) { if (!vd || !vd->hasStorage()) continue; auto &ti = Types.getTypeLowering( - vd->getType(), TypeExpansionContext::maximalResilienceExpansionOnly()); + vd->getTypeInContext(), + TypeExpansionContext::maximalResilienceExpansionOnly()); if (!ti.isTrivial()) return true; } @@ -1666,7 +1667,7 @@ SILFunction *SILGenModule::emitLazyGlobalInitializer(StringRef funcName, auto *onceBuiltin = cast(getBuiltinValueDecl(C, C.getIdentifier("once"))); auto blockParam = onceBuiltin->getParameters()->get(1); - auto *initType = blockParam->getType()->castTo(); + auto *initType = blockParam->getTypeInContext()->castTo(); auto initSILType = cast( Types.getLoweredRValueType(TypeExpansionContext::minimal(), initType)); diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index d6d4a5ca7af5a..c3299ff0ae096 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -7041,7 +7041,7 @@ ManagedValue SILGenFunction::emitReadAsyncLetBinding(SILLocation loc, // Load and reabstract the value if needed. auto genericSig = F.getLoweredFunctionType()->getInvocationGenericSignature(); - auto substVarTy = var->getType()->getReducedType(genericSig); + auto substVarTy = var->getTypeInContext()->getCanonicalType(); auto substAbstraction = AbstractionPattern(genericSig, substVarTy); return emitLoad(loc, visitor.varAddr, substAbstraction, substVarTy, getTypeLowering(substAbstraction, substVarTy), diff --git a/lib/SILGen/SILGenConstructor.cpp b/lib/SILGen/SILGenConstructor.cpp index 86bda3fa007c0..eed3d244e66ae 100644 --- a/lib/SILGen/SILGenConstructor.cpp +++ b/lib/SILGen/SILGenConstructor.cpp @@ -470,7 +470,7 @@ static void emitImplicitValueConstructor(SILGenFunction &SGF, .forwardInto(SGF, Loc, init.get()); ++elti; } else { - assert(field->getType()->getReferenceStorageReferent()->isEqual( + assert(field->getTypeInContext()->getReferenceStorageReferent()->isEqual( field->getParentExecutableInitializer()->getType()) && "Initialization of field with mismatched type!"); @@ -617,7 +617,7 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) { // Get the 'self' decl and type. VarDecl *selfDecl = ctor->getImplicitSelfDecl(); - auto &lowering = getTypeLowering(selfDecl->getType()); + auto &lowering = getTypeLowering(selfDecl->getTypeInContext()); // Decide if we need to do extra work to warn on unsafe behavior in pre-Swift-5 // modes. @@ -731,7 +731,7 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) { SILType::getEmptyTupleType(C), SubstitutionMap::get(zeroInit->getInnermostDeclContext() ->getGenericSignatureOfContext(), - {selfDecl->getType()}, + {selfDecl->getTypeInContext()}, {}), selfLV.getLValueAddress()); } else if (isa(nominal) && nominal->isMoveOnly() @@ -925,7 +925,7 @@ void SILGenFunction::emitClassConstructorAllocator(ConstructorDecl *ctor) { // Allocate the "self" value. VarDecl *selfDecl = ctor->getImplicitSelfDecl(); - SILType selfTy = getLoweredType(selfDecl->getType()); + SILType selfTy = getLoweredType(selfDecl->getTypeInContext()); assert(selfTy.hasReferenceSemantics() && "can't emit a value type ctor here"); @@ -1094,7 +1094,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) { ctor->hasThrows(), ctor->getThrowsLoc(), /*ignored parameters*/ 1); - SILType selfTy = getLoweredLoadableType(selfDecl->getType()); + SILType selfTy = getLoweredLoadableType(selfDecl->getTypeInContext()); ManagedValue selfArg = B.createInputFunctionArgument(selfTy, selfDecl); // is this a designated initializer for a distributed actor? @@ -1328,7 +1328,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) { static ManagedValue emitSelfForMemberInit(SILGenFunction &SGF, SILLocation loc, VarDecl *selfDecl) { - CanType selfFormalType = selfDecl->getType()->getCanonicalType(); + CanType selfFormalType = selfDecl->getTypeInContext()->getCanonicalType(); if (selfFormalType->hasReferenceSemantics()) { return SGF.emitRValueForDecl(loc, selfDecl, selfFormalType, AccessSemantics::DirectToStorage, @@ -1628,7 +1628,7 @@ void SILGenFunction::emitIVarInitializer(SILDeclRef ivarInitializer) { // Emit 'self', then mark it uninitialized. auto selfDecl = cd->getDestructor()->getImplicitSelfDecl(); - SILType selfTy = getLoweredLoadableType(selfDecl->getType()); + SILType selfTy = getLoweredLoadableType(selfDecl->getTypeInContext()); SILValue selfArg = F.begin()->createFunctionArgument(selfTy, selfDecl); SILLocation PrologueLoc(selfDecl); PrologueLoc.markAsPrologue(); diff --git a/lib/SILGen/SILGenDecl.cpp b/lib/SILGen/SILGenDecl.cpp index cb99687a31166..554e38b8a2a03 100644 --- a/lib/SILGen/SILGenDecl.cpp +++ b/lib/SILGen/SILGenDecl.cpp @@ -508,7 +508,7 @@ class LocalVariableInitialization : public SingleBufferInitialization { // The box type's context is lowered in the minimal resilience domain. auto instanceType = SGF.SGM.Types.getLoweredRValueType( - TypeExpansionContext::minimal(), decl->getType()); + TypeExpansionContext::minimal(), decl->getTypeInContext()); // If we have a no implicit copy param decl, make our instance type // @moveOnly. @@ -553,7 +553,7 @@ class LocalVariableInitialization : public SingleBufferInitialization { decl, Box, MarkUnresolvedReferenceBindingInst::Kind::InOut); if (SGF.getASTContext().SILOpts.supportsLexicalLifetimes(SGF.getModule())) { - auto loweredType = SGF.getTypeLowering(decl->getType()).getLoweredType(); + auto loweredType = SGF.getTypeLowering(decl->getTypeInContext()).getLoweredType(); auto lifetime = SGF.F.getLifetime(decl, loweredType); // The box itself isn't lexical--neither a weak reference nor an unsafe // pointer to a box can be formed; and the box doesn't synchronize on @@ -651,9 +651,9 @@ class LetValueInitialization : public Initialization { const TypeLowering *lowering = nullptr; if (vd->isNoImplicitCopy()) { lowering = &SGF.getTypeLowering( - SILMoveOnlyWrappedType::get(vd->getType()->getCanonicalType())); + SILMoveOnlyWrappedType::get(vd->getTypeInContext()->getCanonicalType())); } else { - lowering = &SGF.getTypeLowering(vd->getType()); + lowering = &SGF.getTypeLowering(vd->getTypeInContext()); } // Decide whether we need a temporary stack buffer to evaluate this 'let'. @@ -1439,7 +1439,7 @@ SILGenFunction::emitInitializationForVarDecl(VarDecl *vd, bool forceImmutable, return InitializationPtr(new KnownAddressInitialization(SV)); } - CanType varType = vd->getType()->getCanonicalType(); + CanType varType = vd->getTypeInContext()->getCanonicalType(); assert(!isa(varType) && "local variables should never be inout"); diff --git a/lib/SILGen/SILGenDestructor.cpp b/lib/SILGen/SILGenDestructor.cpp index 23e1d1e87f92c..9cb8c96d375e4 100644 --- a/lib/SILGen/SILGenDestructor.cpp +++ b/lib/SILGen/SILGenDestructor.cpp @@ -300,7 +300,7 @@ void SILGenFunction::emitIVarDestroyer(SILDeclRef ivarDestroyer) { void SILGenFunction::destroyClassMember(SILLocation cleanupLoc, ManagedValue selfValue, VarDecl *D) { - const TypeLowering &ti = getTypeLowering(D->getType()); + const TypeLowering &ti = getTypeLowering(D->getTypeInContext()); if (!ti.isTrivial()) { SILValue addr = B.createRefElementAddr(cleanupLoc, selfValue.getValue(), D, @@ -509,7 +509,7 @@ void SILGenFunction::emitMoveOnlyMemberDestruction(SILValue selfValue, } if (auto *structDecl = dyn_cast(nom)) { for (VarDecl *vd : nom->getStoredProperties()) { - const TypeLowering &ti = getTypeLowering(vd->getType()); + const TypeLowering &ti = getTypeLowering(vd->getTypeInContext()); if (ti.isTrivial()) continue; diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index d09f4974b7bb6..5e1d65763a293 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -971,7 +971,7 @@ RValue RValueEmitter::visitSuperRefExpr(SuperRefExpr *E, SGFContext C) { // If we have a normal self call, then use the emitRValueForDecl call. This // will emit self at +0 since it is guaranteed. ManagedValue Self = - SGF.emitRValueForDecl(E, E->getSelf(), E->getSelf()->getType(), + SGF.emitRValueForDecl(E, E->getSelf(), E->getSelf()->getTypeInContext(), AccessSemantics::Ordinary) .getScalarValue(); @@ -4996,7 +4996,7 @@ namespace { } Type visitNamedPattern(NamedPattern *pattern) { - Type type = LValueType::get(pattern->getDecl()->getType()); + Type type = LValueType::get(pattern->getDecl()->getTypeInContext()); auto declRef = new (SGF.getASTContext()) DeclRefExpr( pattern->getDecl(), DeclNameLoc(), /*Implicit=*/true, AccessSemantics::Ordinary, type); diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp index 14a3d71d7b5e5..8ab7af57ce9d0 100644 --- a/lib/SILGen/SILGenFunction.cpp +++ b/lib/SILGen/SILGenFunction.cpp @@ -1370,7 +1370,7 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) { auto wrapCallArgs = [this, &moduleLoc](SILValue originalValue, FuncDecl *fd, uint32_t paramIndex) -> SILValue { - Type parameterType = fd->getParameters()->get(paramIndex)->getType(); + Type parameterType = fd->getParameters()->get(paramIndex)->getTypeInContext(); SILType paramSILType = SILType::getPrimitiveObjectType(parameterType->getCanonicalType()); // If the types are the same, we don't need to do anything! if (paramSILType == originalValue->getType()) diff --git a/lib/SILGen/SILGenLValue.cpp b/lib/SILGen/SILGenLValue.cpp index b20190b7164cd..bf7e8055e41e5 100644 --- a/lib/SILGen/SILGenLValue.cpp +++ b/lib/SILGen/SILGenLValue.cpp @@ -3090,7 +3090,7 @@ void LValue::addNonMemberVarComponent( LValueTypeData typeData) { assert(!ActorIso); SILType storageType = - SGF.getLoweredType(Storage->getType()).getAddressType(); + SGF.getLoweredType(Storage->getTypeInContext()).getAddressType(); LV.add(Storage, addressor, /*isSuper=*/false, isDirect, Subs, CanType(), typeData, storageType, nullptr, diff --git a/lib/SILGen/SILGenPattern.cpp b/lib/SILGen/SILGenPattern.cpp index d2ccca6958eaa..bedf784733404 100644 --- a/lib/SILGen/SILGenPattern.cpp +++ b/lib/SILGen/SILGenPattern.cpp @@ -2405,7 +2405,7 @@ void PatternMatchEmission::initSharedCaseBlockDest(CaseStmt *caseBlock, continue; // We don't pass address-only values in basic block arguments. - SILType ty = SGF.getLoweredType(vd->getType()); + SILType ty = SGF.getLoweredType(vd->getTypeInContext()); if (ty.isAddressOnly(SGF.F)) continue; block->createPhiArgument(ty, OwnershipKind::Owned, vd); @@ -2435,7 +2435,7 @@ void PatternMatchEmission::emitAddressOnlyAllocations() { if (!vd->hasName()) continue; - SILType ty = SGF.getLoweredType(vd->getType()); + SILType ty = SGF.getLoweredType(vd->getTypeInContext()); if (!ty.isAddressOnly(SGF.F)) continue; assert(!Temporaries[vd]); @@ -2517,7 +2517,7 @@ void PatternMatchEmission::emitSharedCaseBlocks( if (!vd->hasName()) continue; - SILType ty = SGF.getLoweredType(vd->getType()); + SILType ty = SGF.getLoweredType(vd->getTypeInContext()); // Initialize mv at +1. We always pass values in at +1 for today into // shared blocks. diff --git a/lib/SILGen/SILGenProlog.cpp b/lib/SILGen/SILGenProlog.cpp index 56b9f57f136eb..f4f566f371efe 100644 --- a/lib/SILGen/SILGenProlog.cpp +++ b/lib/SILGen/SILGenProlog.cpp @@ -597,7 +597,7 @@ class ArgumentInitHelper { if (pd->hasExternalPropertyWrapper()) pd = cast(pd->getPropertyWrapperBackingProperty()); substFormalParams.push_back( - pd->toFunctionParam(pd->getType()).getCanonical(nullptr)); + pd->toFunctionParam(pd->getTypeInContext()).getCanonical(nullptr)); }; for (auto paramDecl : *paramList) { addParamDecl(paramDecl); @@ -655,7 +655,7 @@ class ArgumentInitHelper { if (FormalParamTypes && FormalParamTypes->isOrigPackExpansion()) { paramValue = argEmitter.handlePackComponent(*FormalParamTypes); } else { - auto substType = pd->getType()->getCanonicalType(); + auto substType = pd->getTypeInContext()->getCanonicalType(); assert(!FormalParamTypes || FormalParamTypes->getSubstParam().getParameterType() == substType); auto origType = (FormalParamTypes ? FormalParamTypes->getOrigType() @@ -731,7 +731,7 @@ class ArgumentInitHelper { auto boxType = SGF.SGM.Types.getContextBoxTypeForCapture( pd, SGF.SGM.Types.getLoweredRValueType(TypeExpansionContext::minimal(), - pd->getType()), + pd->getTypeInContext()), SGF.F.getGenericEnvironment(), /*mutable*/ false); @@ -954,7 +954,7 @@ class ArgumentInitHelper { SILLocation loc(PD); loc.markAsPrologue(); - assert(PD->getType()->isMaterializable()); + assert(PD->getTypeInContext()->isMaterializable()); ++ArgNo; if (PD->hasName() || PD->isIsolated()) { @@ -1012,7 +1012,7 @@ void SILGenFunction::bindParameterForForwarding(ParamDecl *param, param = cast(param->getPropertyWrapperBackingProperty()); } - makeArgument(param->getType(), param, parameters, *this); + makeArgument(param->getTypeInContext(), param, parameters, *this); } void SILGenFunction::bindParametersForForwarding(const ParameterList *params, @@ -1287,7 +1287,7 @@ void SILGenFunction::emitProlog( // Local function to load the expected executor from a local actor auto loadExpectedExecutorForLocalVar = [&](VarDecl *var) { auto loc = RegularLocation::getAutoGeneratedLocation(F.getLocation()); - Type actorType = var->getType(); + Type actorType = var->getTypeInContext(); RValue actorInstanceRV = emitRValueForDecl( loc, var, actorType, AccessSemantics::Ordinary); ManagedValue actorInstance = @@ -1394,7 +1394,7 @@ void SILGenFunction::emitProlog( // uninhabited if (paramList) { for (auto *param : *paramList) { - if (param->getType()->isStructurallyUninhabited()) { + if (param->getTypeInContext()->isStructurallyUninhabited()) { SILLocation unreachableLoc(param); unreachableLoc.markAsPrologue(); B.createUnreachable(unreachableLoc); diff --git a/lib/SILGen/SILGenStmt.cpp b/lib/SILGen/SILGenStmt.cpp index 6f9fc9bb7ee26..99818278968ee 100644 --- a/lib/SILGen/SILGenStmt.cpp +++ b/lib/SILGen/SILGenStmt.cpp @@ -792,7 +792,7 @@ void StmtEmitter::visitDiscardStmt(DiscardStmt *S) { // restriction until we get discard implemented the way we want. for (auto *varDecl : nominal->getStoredProperties()) { assert(varDecl->hasStorage()); - auto varType = varDecl->getType(); + auto varType = varDecl->getTypeInContext(); auto &varTypeLowering = SGF.getTypeLowering(varType); if (!varTypeLowering.isTrivial()) { diagnose(getASTContext(), diff --git a/lib/SILOptimizer/Differentiation/PullbackCloner.cpp b/lib/SILOptimizer/Differentiation/PullbackCloner.cpp index f6ef9a33fdfb7..21ce4a7b0acf2 100644 --- a/lib/SILOptimizer/Differentiation/PullbackCloner.cpp +++ b/lib/SILOptimizer/Differentiation/PullbackCloner.cpp @@ -1176,7 +1176,7 @@ class PullbackCloner::Implementation final } else { auto substMap = tangentVectorTy->getMemberSubstitutionMap( field->getModuleContext(), field); - auto fieldTy = field->getType().subst(substMap); + auto fieldTy = field->getInterfaceType().subst(substMap); auto fieldSILTy = getTypeLowering(fieldTy).getLoweredType(); assert(fieldSILTy.isObject()); eltVals.push_back(makeZeroAdjointValue(fieldSILTy)); @@ -1252,7 +1252,7 @@ class PullbackCloner::Implementation final } else { auto substMap = tangentVectorTy->getMemberSubstitutionMap( field->getModuleContext(), field); - auto fieldTy = field->getType().subst(substMap); + auto fieldTy = field->getInterfaceType().subst(substMap); auto fieldSILTy = getTypeLowering(fieldTy).getLoweredType(); assert(fieldSILTy.isObject()); eltVals.push_back(makeZeroAdjointValue(fieldSILTy)); @@ -2700,7 +2700,7 @@ bool PullbackCloner::Implementation::runForSemanticMemberGetter() { } else { auto substMap = tangentVectorTy->getMemberSubstitutionMap( field->getModuleContext(), field); - auto fieldTy = field->getType().subst(substMap); + auto fieldTy = field->getInterfaceType().subst(substMap); auto fieldSILTy = getTypeLowering(fieldTy).getLoweredType(); assert(fieldSILTy.isObject()); eltVals.push_back(makeZeroAdjointValue(fieldSILTy)); diff --git a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp index 8bc4e0baad255..f83c172357ffe 100644 --- a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp +++ b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp @@ -1454,7 +1454,7 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) { Type selfTy; SILLocation fnLoc = TheMemory.getFunction().getLocation(); if (auto *ctor = fnLoc.getAsASTNode()) - selfTy = ctor->getImplicitSelfDecl()->getType(); + selfTy = ctor->getImplicitSelfDecl()->getTypeInContext(); else selfTy = TheMemory.getASTType(); diff --git a/lib/SILOptimizer/Mandatory/FlowIsolation.cpp b/lib/SILOptimizer/Mandatory/FlowIsolation.cpp index fb8a2b4838f57..cd6e6166eff7c 100644 --- a/lib/SILOptimizer/Mandatory/FlowIsolation.cpp +++ b/lib/SILOptimizer/Mandatory/FlowIsolation.cpp @@ -499,7 +499,7 @@ static bool accessIsConcurrencySafe(ModuleDecl *module, // must be accessible from nonisolated and Sendable return isLetAccessibleAnywhere(module, var) - && isSendableType(module, var->getType()); + && isSendableType(module, var->getTypeInContext()); } /// \returns true iff the ref_element_addr instruction is only used @@ -520,7 +520,7 @@ static bool onlyDeinitAccess(RefElementAddrInst *inst) { static bool diagnoseNonSendableFromDeinit(ModuleDecl *module, RefElementAddrInst *inst) { VarDecl *var = inst->getField(); - Type ty = var->getType(); + Type ty = var->getTypeInContext(); DeclContext* dc = inst->getFunction()->getDeclContext(); // FIXME: we should emit diagnostics in other modes using: diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp index 6bf48c3d7f1d4..e7f44ba1f3a8c 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp @@ -362,7 +362,7 @@ bool SILCombiner::tryOptimizeKeypathOffsetOf(ApplyInst *AI, // generate an undef offset for struct_element_addr of C tail-allocated // arrays. VarDecl *propDecl = component.getStoredPropertyDecl(); - if (propDecl->hasClangNode() && propDecl->getType()->isVoid()) + if (propDecl->hasClangNode() && propDecl->getInterfaceType()->isVoid()) return false; if (!parentTy.getStructOrBoundGenericStruct()) @@ -418,7 +418,7 @@ bool SILCombiner::tryOptimizeKeypathOffsetOf(ApplyInst *AI, if (!intDecl || intDecl->getStoredProperties().size() != 1) return false; VarDecl *member = intDecl->getStoredProperties()[0]; - CanType builtinIntTy = member->getType()->getCanonicalType(); + CanType builtinIntTy = member->getInterfaceType()->getCanonicalType(); if (!isa(builtinIntTy)) return false; diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index d6d9412bbf6c8..25d36fcb3436f 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -1083,7 +1083,7 @@ namespace { const auto calleeParam = calleeParams[idx]; const auto calleeParamType = calleeParam.getParameterType(); - const auto thunkParamType = thunkParamDecl->getType(); + const auto thunkParamType = thunkParamDecl->getTypeInContext(); Expr *paramRef = new (ctx) DeclRefExpr(thunkParamDecl, DeclNameLoc(), /*implicit*/ true); @@ -6362,7 +6362,7 @@ maybeDiagnoseUnsupportedDifferentiableConversion(ConstraintSystem &cs, ctx.Diags.diagnose( expr->getLoc(), diag::invalid_differentiable_function_conversion_expr); - if (paramDecl->getType()->is()) { + if (paramDecl->getInterfaceType()->is()) { auto *typeRepr = paramDecl->getTypeRepr(); while (auto *attributed = dyn_cast(typeRepr)) typeRepr = attributed->getTypeRepr(); diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index c12ee7694a3f8..9514cf912be09 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -2116,7 +2116,7 @@ bool AssignmentFailure::diagnoseAsError() { if (!var->isSettable(DC) || !var->isSetterAccessibleFrom(DC)) return false; - if (!var->getType()->isEqual(VD->getType())) + if (!var->getTypeInContext()->isEqual(VD->getTypeInContext())) return false; // Don't suggest a property if we're in one of its accessors. diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index 439ca84245564..18e928fe78208 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -46,7 +46,7 @@ Expr *swift::buildSelfReference(VarDecl *selfDecl, SelfAccessorKind selfAccessorKind, bool isLValue, Type convertTy) { auto &ctx = selfDecl->getASTContext(); - auto selfTy = selfDecl->getType(); + auto selfTy = selfDecl->getTypeInContext(); switch (selfAccessorKind) { case SelfAccessorKind::Peer: @@ -112,7 +112,7 @@ ArgumentList *swift::buildForwardingArgumentList(ArrayRef params, ASTContext &ctx) { SmallVector args; for (auto *param : params) { - auto type = param->getType(); + auto type = param->getTypeInContext(); Expr *ref = new (ctx) DeclRefExpr(param, DeclNameLoc(), /*implicit*/ true); ref->setType(param->isInOut() ? LValueType::get(type) : type); diff --git a/lib/Sema/ConstantnessSemaDiagnostics.cpp b/lib/Sema/ConstantnessSemaDiagnostics.cpp index 06f2599f4e7ac..11ff5171983cd 100644 --- a/lib/Sema/ConstantnessSemaDiagnostics.cpp +++ b/lib/Sema/ConstantnessSemaDiagnostics.cpp @@ -71,14 +71,14 @@ static bool isParamRequiredToBeConstant(AbstractFunctionDecl *funcDecl, ParamDec // We are looking at a top-level os_log function that accepts level and // possibly custom log object. Those need not be constants, but every other // parameter must be. - paramType = param->getType(); + paramType = param->getTypeInContext(); nominal = paramType->getNominalOrBoundGenericNominal(); return !nominal || !isOSLogDynamicObject(nominal); } if (!hasSemanticsAttr(funcDecl, semantics::ATOMICS_REQUIRES_CONSTANT_ORDERINGS)) return false; - paramType = param->getType(); + paramType = param->getTypeInContext(); structDecl = paramType->getStructOrBoundGenericStruct(); if (!structDecl) return false; diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index f96e92a316a09..fae5d7d9500ba 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -1407,7 +1407,7 @@ Type ConstraintSystem::getUnopenedTypeOfReference( return ErrorType::get(getASTContext()); } - return wantInterfaceType ? var->getInterfaceType() : var->getType(); + return wantInterfaceType ? var->getInterfaceType() : var->getTypeInContext(); }, memberLocator, wantInterfaceType, adjustForPreconcurrency, GetClosureType{*this}, @@ -7202,7 +7202,7 @@ void ConstraintSystem::recordFixedRequirement(ConstraintLocator *reqLocator, // Replace any error types encountered with placeholders. Type ConstraintSystem::getVarType(const VarDecl *var) { - auto type = var->getType(); + auto type = var->getTypeInContext(); // If this declaration is used as part of a code completion // expression, solver needs to glance over the fact that diff --git a/lib/Sema/DerivedConformanceActor.cpp b/lib/Sema/DerivedConformanceActor.cpp index b43445a7475b8..70018effb07e1 100644 --- a/lib/Sema/DerivedConformanceActor.cpp +++ b/lib/Sema/DerivedConformanceActor.cpp @@ -104,7 +104,7 @@ deriveBodyActor_unownedExecutor(AbstractFunctionDecl *getter, void *) { }; // Build a reference to self. - Type selfType = getter->getImplicitSelfDecl()->getType(); + Type selfType = getter->getImplicitSelfDecl()->getTypeInContext(); Expr *selfArg = DerivedConformance::createSelfDeclRef(getter); selfArg->setType(selfType); diff --git a/lib/Sema/DerivedConformanceCodable.cpp b/lib/Sema/DerivedConformanceCodable.cpp index 77f1ad1e12860..98d9920620bae 100644 --- a/lib/Sema/DerivedConformanceCodable.cpp +++ b/lib/Sema/DerivedConformanceCodable.cpp @@ -342,7 +342,7 @@ static bool validateCodingKeysEnum(const DerivedConformance &derived, .isInvalid()) { TypeLoc typeLoc = { it->second->getTypeReprOrParentPatternTypeRepr(), - it->second->getType(), + it->second->getTypeInContext(), }; auto var = it->second; diff --git a/lib/Sema/DerivedConformanceComparable.cpp b/lib/Sema/DerivedConformanceComparable.cpp index fb9aaaa59f115..a98050fcd3d3f 100644 --- a/lib/Sema/DerivedConformanceComparable.cpp +++ b/lib/Sema/DerivedConformanceComparable.cpp @@ -41,8 +41,8 @@ deriveBodyComparable_enum_uninhabited_lt(AbstractFunctionDecl *ltDecl, void *) { auto aParam = args->get(0); auto bParam = args->get(1); - assert(!cast(aParam->getType()->getAnyNominal())->hasCases()); - assert(!cast(bParam->getType()->getAnyNominal())->hasCases()); + assert(!cast(aParam->getInterfaceType()->getAnyNominal())->hasCases()); + assert(!cast(bParam->getInterfaceType()->getAnyNominal())->hasCases()); SmallVector statements; auto body = BraceStmt::create(C, SourceLoc(), statements, SourceLoc()); @@ -62,7 +62,7 @@ deriveBodyComparable_enum_noAssociatedValues_lt(AbstractFunctionDecl *ltDecl, auto aParam = args->get(0); auto bParam = args->get(1); - auto enumDecl = cast(aParam->getType()->getAnyNominal()); + auto enumDecl = cast(aParam->getInterfaceType()->getAnyNominal()); // Generate the conversion from the enums to integer indices. SmallVector statements; @@ -98,8 +98,8 @@ deriveBodyComparable_enum_hasAssociatedValues_lt(AbstractFunctionDecl *ltDecl, v auto aParam = args->get(0); auto bParam = args->get(1); - Type enumType = aParam->getType(); - auto enumDecl = cast(aParam->getType()->getAnyNominal()); + Type enumType = aParam->getTypeInContext(); + auto enumDecl = cast(aParam->getInterfaceType()->getAnyNominal()); SmallVector statements; SmallVector cases; diff --git a/lib/Sema/DerivedConformanceDifferentiable.cpp b/lib/Sema/DerivedConformanceDifferentiable.cpp index 5671e995cc676..fbeba88e4f8a8 100644 --- a/lib/Sema/DerivedConformanceDifferentiable.cpp +++ b/lib/Sema/DerivedConformanceDifferentiable.cpp @@ -266,7 +266,7 @@ deriveBodyDifferentiable_move(AbstractFunctionDecl *funcDecl, void *) { // Create reference to parameter member: `offset.`. VarDecl *paramMember = nullptr; - auto *paramNominal = paramDecl->getType()->getAnyNominal(); + auto *paramNominal = paramDecl->getTypeInContext()->getAnyNominal(); assert(paramNominal && "Parameter should have a nominal type"); // Find parameter member corresponding to returned nominal member. for (auto *candidate : paramNominal->getStoredProperties()) { @@ -571,7 +571,7 @@ static void checkAndDiagnoseImplicitNoDerivative(ASTContext &Context, .diagnose( loc, diag::differentiable_nondiff_type_implicit_noderivative_fixit, - vd->getName(), vd->getType(), nominal->getName(), + vd->getName(), vd->getTypeInContext(), nominal->getName(), nominalCanDeriveAdditiveArithmetic) .fixItInsert(loc, "@noDerivative "); continue; diff --git a/lib/Sema/DerivedConformanceDistributedActor.cpp b/lib/Sema/DerivedConformanceDistributedActor.cpp index e54d99e132e10..20d893565c37c 100644 --- a/lib/Sema/DerivedConformanceDistributedActor.cpp +++ b/lib/Sema/DerivedConformanceDistributedActor.cpp @@ -649,7 +649,7 @@ deriveBodyDistributedActor_unownedExecutor(AbstractFunctionDecl *getter, void *) }; // Build a reference to self. - Type selfType = getter->getImplicitSelfDecl()->getType(); + Type selfType = getter->getImplicitSelfDecl()->getTypeInContext(); Expr *selfArg = DerivedConformance::createSelfDeclRef(getter); selfArg->setType(selfType); @@ -694,7 +694,7 @@ deriveBodyDistributedActor_unownedExecutor(AbstractFunctionDecl *getter, void *) [&](SubstitutableType *dependentType) { if (auto gp = dyn_cast(dependentType)) { if (gp->getDepth() == 0 && gp->getIndex() == 0) { - return getter->getImplicitSelfDecl()->getType(); + return getter->getImplicitSelfDecl()->getTypeInContext(); } } diff --git a/lib/Sema/DerivedConformanceEquatableHashable.cpp b/lib/Sema/DerivedConformanceEquatableHashable.cpp index 90248c7cc6229..4559c880e711d 100644 --- a/lib/Sema/DerivedConformanceEquatableHashable.cpp +++ b/lib/Sema/DerivedConformanceEquatableHashable.cpp @@ -70,7 +70,7 @@ deriveBodyEquatable_enum_uninhabited_eq(AbstractFunctionDecl *eqDecl, void *) { auto aParam = args->get(0); auto bParam = args->get(1); - assert(!cast(aParam->getType()->getAnyNominal())->hasCases()); + assert(!cast(aParam->getInterfaceType()->getAnyNominal())->hasCases()); SmallVector statements; SmallVector cases; @@ -78,11 +78,11 @@ deriveBodyEquatable_enum_uninhabited_eq(AbstractFunctionDecl *eqDecl, void *) { // switch (a, b) { } auto aRef = new (C) DeclRefExpr(aParam, DeclNameLoc(), /*implicit*/ true, AccessSemantics::Ordinary, - aParam->getType()); + aParam->getTypeInContext()); auto bRef = new (C) DeclRefExpr(bParam, DeclNameLoc(), /*implicit*/ true, AccessSemantics::Ordinary, - bParam->getType()); - TupleTypeElt abTupleElts[2] = { aParam->getType(), bParam->getType() }; + bParam->getTypeInContext()); + TupleTypeElt abTupleElts[2] = { aParam->getTypeInContext(), bParam->getTypeInContext() }; auto abExpr = TupleExpr::createImplicit(C, {aRef, bRef}, /*labels*/ {}); abExpr->setType(TupleType::get(abTupleElts, C)); auto switchStmt = @@ -106,7 +106,7 @@ deriveBodyEquatable_enum_noAssociatedValues_eq(AbstractFunctionDecl *eqDecl, auto aParam = args->get(0); auto bParam = args->get(1); - auto enumDecl = cast(aParam->getType()->getAnyNominal()); + auto enumDecl = cast(aParam->getInterfaceType()->getAnyNominal()); // Generate the conversion from the enums to integer indices. SmallVector statements; @@ -163,8 +163,8 @@ deriveBodyEquatable_enum_hasAssociatedValues_eq(AbstractFunctionDecl *eqDecl, auto aParam = args->get(0); auto bParam = args->get(1); - Type enumType = aParam->getType(); - auto enumDecl = cast(aParam->getType()->getAnyNominal()); + Type enumType = aParam->getTypeInContext(); + auto enumDecl = cast(aParam->getInterfaceType()->getAnyNominal()); SmallVector statements; SmallVector cases; @@ -299,7 +299,7 @@ deriveBodyEquatable_struct_eq(AbstractFunctionDecl *eqDecl, void *) { auto aParam = args->get(0); auto bParam = args->get(1); - auto structDecl = cast(aParam->getType()->getAnyNominal()); + auto structDecl = cast(aParam->getInterfaceType()->getAnyNominal()); SmallVector statements; @@ -688,7 +688,7 @@ deriveBodyHashable_enum_hasAssociatedValues_hashInto( auto enumDecl = parentDC->getSelfEnumDecl(); auto selfDecl = hashIntoDecl->getImplicitSelfDecl(); - Type enumType = selfDecl->getType(); + Type enumType = selfDecl->getTypeInContext(); // Extract the decl for the hasher parameter. auto hasherParam = hashIntoDecl->getParameters()->get(0); @@ -828,7 +828,7 @@ deriveBodyHashable_hashValue(AbstractFunctionDecl *hashValueDecl, void *) { // 'self' auto selfDecl = hashValueDecl->getImplicitSelfDecl(); - Type selfType = selfDecl->getType(); + Type selfType = selfDecl->getTypeInContext(); auto selfRef = new (C) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true, AccessSemantics::Ordinary, diff --git a/lib/Sema/DerivedConformances.cpp b/lib/Sema/DerivedConformances.cpp index ea628fb36a5c2..f4049965d166d 100644 --- a/lib/Sema/DerivedConformances.cpp +++ b/lib/Sema/DerivedConformances.cpp @@ -755,7 +755,7 @@ DeclRefExpr *DerivedConformance::convertEnumToIndex(SmallVectorImpl &st AbstractFunctionDecl *funcDecl, const char *indexName) { ASTContext &C = enumDecl->getASTContext(); - Type enumType = enumVarDecl->getType(); + Type enumType = enumVarDecl->getTypeInContext(); Type intType = C.getIntType(); auto indexVar = new (C) VarDecl(/*IsStatic*/false, VarDecl::Introducer::Var, @@ -812,7 +812,7 @@ DeclRefExpr *DerivedConformance::convertEnumToIndex(SmallVectorImpl &st auto enumRef = new (C) DeclRefExpr(enumVarDecl, DeclNameLoc(), /*implicit*/true, AccessSemantics::Ordinary, - enumVarDecl->getType()); + enumVarDecl->getTypeInContext()); auto switchStmt = SwitchStmt::createImplicit(LabeledStmtInfo(), enumRef, cases, C); diff --git a/lib/Sema/IDETypeCheckingRequests.cpp b/lib/Sema/IDETypeCheckingRequests.cpp index 76633cc142ee9..12c5e349a750b 100644 --- a/lib/Sema/IDETypeCheckingRequests.cpp +++ b/lib/Sema/IDETypeCheckingRequests.cpp @@ -212,7 +212,7 @@ RootAndResultTypeOfKeypathDynamicMemberRequest::evaluate(Evaluator &evaluator, return TypePair(); const auto *param = subscript->getIndices()->get(0); - auto keyPathType = param->getType()->getAs(); + auto keyPathType = param->getTypeInContext()->getAs(); if (!keyPathType) return TypePair(); auto genericArgs = keyPathType->getGenericArgs(); diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index ba9c282ad9b13..df2fcd69dfedd 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -1589,7 +1589,7 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) { static bool closureHasWeakSelfCapture(const AbstractClosureExpr *ACE) { if (auto closureExpr = dyn_cast(ACE)) { if (auto selfDecl = closureExpr->getCapturedSelfDecl()) { - return selfDecl->getType()->is(); + return selfDecl->getInterfaceType()->is(); } } @@ -1932,7 +1932,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E, // If we've already captured something with the name "self" other than // the actual self param, offer special diagnostics. if (auto *VD = closureExpr->getCapturedSelfDecl()) { - if (!VD->getType()->is()) { + if (!VD->getInterfaceType()->is()) { Diags.diagnose(VD->getLoc(), diag::note_other_self_capture); } @@ -3376,7 +3376,7 @@ VarDeclUsageChecker::~VarDeclUsageChecker() { // If this variable has WeakStorageType, then it can be mutated in ways we // don't know. - if (var->getType()->is()) + if (var->getInterfaceType()->is()) access |= RK_Written; // Diagnose variables that were never used (other than their diff --git a/lib/Sema/PCMacro.cpp b/lib/Sema/PCMacro.cpp index 7bc64ddd175da..de591c318ff82 100644 --- a/lib/Sema/PCMacro.cpp +++ b/lib/Sema/PCMacro.cpp @@ -518,7 +518,7 @@ class Instrumenter : InstrumenterBase { VD->setInterfaceType(MaybeLoadInitExpr->getType()->mapTypeOutOfContext()); VD->setImplicit(); - NamedPattern *NP = NamedPattern::createImplicit(Context, VD, VD->getType()); + NamedPattern *NP = NamedPattern::createImplicit(Context, VD, VD->getTypeInContext()); PatternBindingDecl *PBD = PatternBindingDecl::createImplicit( Context, StaticSpellingKind::None, NP, MaybeLoadInitExpr, TypeCheckDC); diff --git a/lib/Sema/PlaygroundTransform.cpp b/lib/Sema/PlaygroundTransform.cpp index d58e519db6276..c96477db0ebd9 100644 --- a/lib/Sema/PlaygroundTransform.cpp +++ b/lib/Sema/PlaygroundTransform.cpp @@ -616,7 +616,7 @@ class Instrumenter : InstrumenterBase { DeclBaseName Name = PD->getName(); Expr *PVVarRef = new (Context) DeclRefExpr(PD, DeclNameLoc(), /*implicit=*/true, - AccessSemantics::Ordinary, PD->getType()); + AccessSemantics::Ordinary, PD->getTypeInContext()); Added Log(buildLoggerCall(PVVarRef, PD->getSourceRange(), Name.getIdentifier().str())); if (*Log) { @@ -770,7 +770,7 @@ class Instrumenter : InstrumenterBase { VD->setInterfaceType(MaybeLoadInitExpr->getType()->mapTypeOutOfContext()); VD->setImplicit(); - NamedPattern *NP = NamedPattern::createImplicit(Context, VD, VD->getType()); + NamedPattern *NP = NamedPattern::createImplicit(Context, VD, VD->getTypeInContext()); PatternBindingDecl *PBD = PatternBindingDecl::createImplicit( Context, StaticSpellingKind::None, NP, MaybeLoadInitExpr, TypeCheckDC); diff --git a/lib/Sema/SyntacticElementTarget.cpp b/lib/Sema/SyntacticElementTarget.cpp index 1239ab9d6b3f4..2b36862cd946d 100644 --- a/lib/Sema/SyntacticElementTarget.cpp +++ b/lib/Sema/SyntacticElementTarget.cpp @@ -187,7 +187,7 @@ SyntacticElementTarget::forForEachStmt(ForEachStmt *stmt, DeclContext *dc, SyntacticElementTarget SyntacticElementTarget::forPropertyWrapperInitializer( VarDecl *wrappedVar, DeclContext *dc, Expr *initializer) { SyntacticElementTarget target(initializer, dc, CTP_Initialization, - wrappedVar->getType(), + wrappedVar->getTypeInContext(), /*isDiscarded=*/false); target.expression.propertyWrapper.wrappedVar = wrappedVar; if (auto *patternBinding = wrappedVar->getParentPatternBinding()) { diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 5ad2ba82a6366..cc141c8ba45f9 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -854,7 +854,7 @@ void AttributeChecker::visitIBOutletAttr(IBOutletAttr *attr) { } // Verify that the field type is valid as an outlet. - auto type = VD->getType(); + auto type = VD->getTypeInContext(); if (VD->isInvalid()) return; @@ -1636,7 +1636,7 @@ bool swift::isValidDynamicCallableMethod(FuncDecl *decl, ModuleDecl *module, auto paramList = decl->getParameters(); if (paramList->size() != 1 || paramList->get(0)->isVariadic()) return false; - auto argType = paramList->get(0)->getType(); + auto argType = paramList->get(0)->getTypeInContext(); // If non-keyword (positional) arguments, check that argument type conforms to // `ExpressibleByArrayLiteral`. @@ -1744,7 +1744,7 @@ bool swift::isValidStringDynamicMemberLookup(SubscriptDecl *decl, return false; const auto *param = decl->getIndices()->get(0); - auto paramType = param->getType(); + auto paramType = param->getTypeInContext(); // If this is `subscript(dynamicMember: String*)` return TypeChecker::conformsToKnownProtocol( @@ -6966,13 +6966,13 @@ void AttributeChecker::visitEagerMoveAttr(EagerMoveAttr *attr) { } if (auto *func = dyn_cast(D)) { auto *self = func->getImplicitSelfDecl(); - if (self && self->getType()->isPureMoveOnly()) { + if (self && self->getTypeInContext()->isPureMoveOnly()) { diagnoseAndRemoveAttr(attr, diag::eagermove_and_noncopyable_combined); return; } } if (auto *pd = dyn_cast(D)) { - if (pd->getType()->isPureMoveOnly()) { + if (pd->getTypeInContext()->isPureMoveOnly()) { diagnoseAndRemoveAttr(attr, diag::eagermove_and_noncopyable_combined); return; } @@ -7017,7 +7017,7 @@ void AttributeChecker::visitCompilerInitializedAttr( // Because optionals are implicitly initialized to nil according to the // language, this attribute doesn't make sense on optionals. - if (var->getType()->isOptional()) { + if (var->getTypeInContext()->isOptional()) { diagnose(attr->getLocation(), diag::optional_compilerinitialized); return; } @@ -7342,8 +7342,8 @@ static bool parametersMatch(const AbstractFunctionDecl *a, return false; for (auto index : indices(*aParams)) { - auto aParamType = aParams->get(index)->getType(); - auto bParamType = bParams->get(index)->getType(); + auto aParamType = aParams->get(index)->getTypeInContext(); + auto bParamType = bParams->get(index)->getTypeInContext(); if (!aParamType->matchesParameter(bParamType, TypeMatchOptions())) return false; } diff --git a/lib/Sema/TypeCheckCaptures.cpp b/lib/Sema/TypeCheckCaptures.cpp index c0e193f712ee1..2cca15b3f0e57 100644 --- a/lib/Sema/TypeCheckCaptures.cpp +++ b/lib/Sema/TypeCheckCaptures.cpp @@ -206,7 +206,7 @@ class FindCapturedVars : public ASTWalker { if (VD->hasInterfaceType() && (!ObjC || !isa(VD) - || !cast(VD)->getType()->hasRetainablePointerRepresentation())) + || !cast(VD)->getTypeInContext()->hasRetainablePointerRepresentation())) checkType(VD->getInterfaceType(), VD->getLoc()); } diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index b60db83eb6bdb..eac5c0ab65b1d 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -1043,7 +1043,7 @@ bool swift::diagnoseNonSendableTypesInReference( if (auto var = dyn_cast(declRef.getDecl())) { Type propertyType = var->isLocalCapture() - ? var->getType() + ? var->getTypeInContext() : var->getValueInterfaceType().subst(subs); if (diagnoseNonSendableTypes( propertyType, fromDC, refLoc, @@ -1300,13 +1300,13 @@ void swift::tryDiagnoseExecutorConformance(ASTContext &C, StructDecl *legacyJobDecl = C.getJobDecl(); StructDecl *unownedJobDecl = C.getUnownedJobDecl(); - if (executorJobDecl && param->getType()->isEqual(executorJobDecl->getDeclaredInterfaceType())) { + if (executorJobDecl && param->getInterfaceType()->isEqual(executorJobDecl->getDeclaredInterfaceType())) { assert(moveOnlyEnqueueRequirement == nullptr); moveOnlyEnqueueRequirement = funcDecl; - } else if (legacyJobDecl && param->getType()->isEqual(legacyJobDecl->getDeclaredInterfaceType())) { + } else if (legacyJobDecl && param->getInterfaceType()->isEqual(legacyJobDecl->getDeclaredInterfaceType())) { assert(legacyMoveOnlyEnqueueRequirement == nullptr); legacyMoveOnlyEnqueueRequirement = funcDecl; - } else if (unownedJobDecl && param->getType()->isEqual(unownedJobDecl->getDeclaredInterfaceType())) { + } else if (unownedJobDecl && param->getInterfaceType()->isEqual(unownedJobDecl->getDeclaredInterfaceType())) { assert(unownedEnqueueRequirement == nullptr); unownedEnqueueRequirement = funcDecl; } diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp index 1b3ed5d151785..33f925a7f8b80 100644 --- a/lib/Sema/TypeCheckConstraints.cpp +++ b/lib/Sema/TypeCheckConstraints.cpp @@ -815,7 +815,7 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer, // Don't change the type of a variable that we've been able to // compute a type for. if (var->hasInterfaceType() && - !var->getType()->hasUnboundGenericType() && + !var->getTypeInContext()->hasUnboundGenericType() && !var->isInvalid()) return; diff --git a/lib/Sema/TypeCheckDeclObjC.cpp b/lib/Sema/TypeCheckDeclObjC.cpp index 545930f59587a..d35cf65b61036 100644 --- a/lib/Sema/TypeCheckDeclObjC.cpp +++ b/lib/Sema/TypeCheckDeclObjC.cpp @@ -295,7 +295,7 @@ static void diagnoseFunctionParamNotRepresentable( } else { if (auto typeRepr = P->getTypeRepr()) SR = typeRepr->getSourceRange(); - diagnoseTypeNotRepresentableInObjC(AFD, P->getType(), SR, behavior); + diagnoseTypeNotRepresentableInObjC(AFD, P->getTypeInContext(), SR, behavior); } Reason.describe(AFD); } @@ -336,7 +336,7 @@ static bool isParamListRepresentableInObjC(const AbstractFunctionDecl *AFD, return false; } - if (param->getType()->hasError()) + if (param->getTypeInContext()->hasError()) return false; if (param->hasAttachedPropertyWrapper()) { @@ -344,7 +344,7 @@ static bool isParamListRepresentableInObjC(const AbstractFunctionDecl *AFD, ForeignLanguage::ObjectiveC, const_cast(AFD))) continue; - } else if (param->getType()->isRepresentableIn( + } else if (param->getTypeInContext()->isRepresentableIn( ForeignLanguage::ObjectiveC, const_cast(AFD))) { continue; @@ -354,7 +354,7 @@ static bool isParamListRepresentableInObjC(const AbstractFunctionDecl *AFD, // foreign error convention that replaces NSErrorPointer with () // and this is the replaced parameter. AbstractFunctionDecl *overridden; - if (param->getType()->isVoid() && AFD->hasThrows() && + if (param->getTypeInContext()->isVoid() && AFD->hasThrows() && (overridden = AFD->getOverriddenDecl())) { auto foreignError = overridden->getForeignErrorConvention(); if (foreignError && @@ -988,7 +988,7 @@ bool swift::isRepresentableInObjC( while (errorParameterIndex > 0) { // Skip over trailing closures. - auto type = paramList->get(errorParameterIndex - 1)->getType(); + auto type = paramList->get(errorParameterIndex - 1)->getTypeInContext(); // It can't be a trailing closure unless it has a specific form. // Only consider the rvalue type. diff --git a/lib/Sema/TypeCheckDeclOverride.cpp b/lib/Sema/TypeCheckDeclOverride.cpp index 24c4247e3f643..0ce87a7ab0e30 100644 --- a/lib/Sema/TypeCheckDeclOverride.cpp +++ b/lib/Sema/TypeCheckDeclOverride.cpp @@ -338,8 +338,8 @@ diagnoseMismatchedOptionals(const ValueDecl *member, // Check the parameter types. auto checkParam = [&](const ParamDecl *decl, const ParamDecl *parentDecl) { - Type paramTy = decl->getType(); - Type parentParamTy = parentDecl->getType(); + Type paramTy = decl->getTypeInContext(); + Type parentParamTy = parentDecl->getTypeInContext(); auto *repr = decl->getTypeRepr(); if (!repr) diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index a0fb1d6909cb6..027a702eac185 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -399,7 +399,7 @@ static void checkForEmptyOptionSet(const VarDecl *VD) { auto DC = VD->getDeclContext(); // Make sure property is of same type as the type it is declared in - if (!VD->getType()->isEqual(DC->getSelfTypeInContext())) + if (!VD->getInterfaceType()->isEqual(DC->getSelfInterfaceType())) return; // Make sure this type conforms to OptionSet @@ -1131,7 +1131,7 @@ Expr *DefaultArgumentExprRequest::evaluate(Evaluator &evaluator, } auto &ctx = param->getASTContext(); - auto paramTy = param->getType(); + auto paramTy = param->getTypeInContext(); auto *initExpr = param->getStructuralDefaultExpr(); assert(initExpr); @@ -2268,7 +2268,7 @@ class DeclChecker : public DeclVisitor { // NOTE: We do this here instead of TypeCheckAttr since types are not // completely type checked at that point. if (auto attr = VD->getAttrs().getAttribute()) { - if (auto *nom = VD->getType()->getCanonicalType()->getNominalOrBoundGenericNominal()) { + if (auto *nom = VD->getInterfaceType()->getNominalOrBoundGenericNominal()) { if (nom->isMoveOnly()) { DE.diagnose(attr->getLocation(), diag::noimplicitcopy_attr_not_allowed_on_moveonlytype) @@ -3965,7 +3965,7 @@ void TypeChecker::checkParameterList(ParameterList *params, // If we have a noimplicitcopy parameter, make sure that the underlying type // is not move only. It is redundant. if (auto attr = param->getAttrs().getAttribute()) { - if (auto *nom = param->getType()->getCanonicalType()->getNominalOrBoundGenericNominal()) { + if (auto *nom = param->getInterfaceType()->getNominalOrBoundGenericNominal()) { if (nom->isMoveOnly()) { param->diagnose(diag::noimplicitcopy_attr_not_allowed_on_moveonlytype) .fixItRemove(attr->getRange()); diff --git a/lib/Sema/TypeCheckExpr.cpp b/lib/Sema/TypeCheckExpr.cpp index b13aa3318d39d..d0968b391a1e5 100644 --- a/lib/Sema/TypeCheckExpr.cpp +++ b/lib/Sema/TypeCheckExpr.cpp @@ -585,7 +585,7 @@ Expr *TypeChecker::buildCheckedRefExpr(VarDecl *value, DeclContext *UseDC, DeclNameLoc loc, bool Implicit) { auto type = constraints::ConstraintSystem::getUnopenedTypeOfReference( value, Type(), UseDC, - [&](VarDecl *var) -> Type { return value->getType(); }); + [&](VarDecl *var) -> Type { return value->getTypeInContext(); }); auto semantics = value->getAccessSemanticsFromContext(UseDC, /*isAccessOnSelf*/false); return new (value->getASTContext()) diff --git a/lib/Sema/TypeCheckPattern.cpp b/lib/Sema/TypeCheckPattern.cpp index 33519b7bdf03b..1f4d2529f5fe6 100644 --- a/lib/Sema/TypeCheckPattern.cpp +++ b/lib/Sema/TypeCheckPattern.cpp @@ -1725,7 +1725,7 @@ void TypeChecker::coerceParameterListToType(ParameterList *P, // Local function to check whether type of given parameter // should be coerced to a given contextual type or not. auto shouldOverwriteParam = [&](ParamDecl *param) -> bool { - return !isValidType(param->getType()); + return !isValidType(param->getTypeInContext()); }; auto handleParameter = [&](ParamDecl *param, Type ty, bool forceMutable) { diff --git a/lib/Sema/TypeCheckPropertyWrapper.cpp b/lib/Sema/TypeCheckPropertyWrapper.cpp index ff4cf7e41ae8d..77563315d5949 100644 --- a/lib/Sema/TypeCheckPropertyWrapper.cpp +++ b/lib/Sema/TypeCheckPropertyWrapper.cpp @@ -261,7 +261,7 @@ static bool enclosingInstanceTypeIsNever(ASTContext &ctx, SubscriptDecl *subscri if (param->getArgumentName() != ctx.Id_enclosingInstance) return false; - auto paramTy = param->getType(); + auto paramTy = param->getTypeInContext(); auto neverTy = ctx.getNeverType(); return neverTy->isEqual(paramTy); } diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index 116f19c344a45..27cd1eedcc69d 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -940,10 +940,10 @@ static void checkFallthroughPatternBindingsAndTypes( continue; } - if (!previous->getType()->isEqual(expected->getType())) { + if (!previous->getTypeInContext()->isEqual(expected->getTypeInContext())) { ctx.Diags.diagnose( previous->getLoc(), diag::type_mismatch_fallthrough_pattern_list, - previous->getType(), expected->getType()); + previous->getTypeInContext(), expected->getTypeInContext()); previous->setInvalid(); expected->setInvalid(); } @@ -1544,10 +1544,10 @@ class StmtChecker : public StmtVisitor { assert(isa(initialCaseVarDecl->getParentPatternStmt())); if (!initialCaseVarDecl->isInvalid() && - !vd->getType()->isEqual(initialCaseVarDecl->getType())) { + !vd->getInterfaceType()->isEqual(initialCaseVarDecl->getInterfaceType())) { getASTContext().Diags.diagnose( vd->getLoc(), diag::type_mismatch_multiple_pattern_list, - vd->getType(), initialCaseVarDecl->getType()); + vd->getInterfaceType(), initialCaseVarDecl->getInterfaceType()); vd->setInvalid(); initialCaseVarDecl->setInvalid(); } diff --git a/lib/Sema/TypeCheckStorage.cpp b/lib/Sema/TypeCheckStorage.cpp index 89d46decbaf11..8766bc0f89f52 100644 --- a/lib/Sema/TypeCheckStorage.cpp +++ b/lib/Sema/TypeCheckStorage.cpp @@ -959,7 +959,7 @@ static Expr *buildStorageReference(AccessorDecl *accessor, AccessSemantics semantics; SelfAccessorKind selfAccessKind; - Type selfTypeForAccess = (selfDecl ? selfDecl->getType() : Type()); + Type selfTypeForAccess = (selfDecl ? selfDecl->getTypeInContext() : Type()); bool isMemberLValue = isLValue; @@ -1263,7 +1263,7 @@ static ProtocolConformanceRef checkConformanceToNSCopying(VarDecl *var, } static std::pair getUnderlyingTypeOfVariable(VarDecl *var) { - Type type = var->getType()->getReferenceStorageReferent(); + Type type = var->getTypeInContext()->getReferenceStorageReferent(); if (Type objectType = type->getOptionalObjectType()) { return {objectType, true}; @@ -1562,7 +1562,7 @@ synthesizeLazyGetterBody(AccessorDecl *Get, VarDecl *VD, VarDecl *Storage, Tmp1VD->setInterfaceType(VD->getValueInterfaceType()); Tmp1VD->setImplicit(); - auto *Named = NamedPattern::createImplicit(Ctx, Tmp1VD, Tmp1VD->getType()); + auto *Named = NamedPattern::createImplicit(Ctx, Tmp1VD, Tmp1VD->getTypeInContext()); auto *Let = BindingPattern::createImplicit(Ctx, VarDecl::Introducer::Let, Named); Let->setType(Named->getType()); @@ -1578,7 +1578,7 @@ synthesizeLazyGetterBody(AccessorDecl *Get, VarDecl *VD, VarDecl *Storage, // Build the early return inside the if. auto *Tmp1DRE = new (Ctx) DeclRefExpr(Tmp1VD, DeclNameLoc(), /*Implicit*/true, AccessSemantics::Ordinary); - Tmp1DRE->setType(Tmp1VD->getType()); + Tmp1DRE->setType(Tmp1VD->getTypeInContext()); auto *Return = new (Ctx) ReturnStmt(SourceLoc(), Tmp1DRE, /*implicit*/true); @@ -1612,7 +1612,7 @@ synthesizeLazyGetterBody(AccessorDecl *Get, VarDecl *VD, VarDecl *Storage, InitValue = PBD->getInit(entryIndex); } else { - InitValue = new (Ctx) ErrorExpr(SourceRange(), Tmp2VD->getType()); + InitValue = new (Ctx) ErrorExpr(SourceRange(), Tmp2VD->getTypeInContext()); } // Recontextualize any closure declcontexts nested in the initializer to @@ -1628,9 +1628,9 @@ synthesizeLazyGetterBody(AccessorDecl *Get, VarDecl *VD, VarDecl *Storage, InitValue->setType(initType); Pattern *Tmp2PBDPattern = - NamedPattern::createImplicit(Ctx, Tmp2VD, Tmp2VD->getType()); + NamedPattern::createImplicit(Ctx, Tmp2VD, Tmp2VD->getTypeInContext()); Tmp2PBDPattern = - TypedPattern::createImplicit(Ctx, Tmp2PBDPattern, Tmp2VD->getType()); + TypedPattern::createImplicit(Ctx, Tmp2PBDPattern, Tmp2VD->getTypeInContext()); auto *Tmp2PBD = PatternBindingDecl::createImplicit( Ctx, StaticSpellingKind::None, Tmp2PBDPattern, InitValue, Get, @@ -1641,14 +1641,14 @@ synthesizeLazyGetterBody(AccessorDecl *Get, VarDecl *VD, VarDecl *Storage, // Assign tmp2 into storage. auto Tmp2DRE = new (Ctx) DeclRefExpr(Tmp2VD, DeclNameLoc(), /*Implicit*/true, AccessSemantics::DirectToStorage); - Tmp2DRE->setType(Tmp2VD->getType()); + Tmp2DRE->setType(Tmp2VD->getTypeInContext()); createPropertyStoreOrCallSuperclassSetter(Get, Tmp2DRE, Storage, TargetImpl::Storage, Body, Ctx); // Return tmp2. Tmp2DRE = new (Ctx) DeclRefExpr(Tmp2VD, DeclNameLoc(), /*Implicit*/true, AccessSemantics::DirectToStorage); - Tmp2DRE->setType(Tmp2VD->getType()); + Tmp2DRE->setType(Tmp2VD->getTypeInContext()); Body.push_back(new (Ctx) ReturnStmt(SourceLoc(), Tmp2DRE, /*implicit*/true)); @@ -1729,7 +1729,7 @@ synthesizeTrivialSetterBodyWithStorage(AccessorDecl *setter, auto *valueDRE = new (ctx) DeclRefExpr(valueParamDecl, DeclNameLoc(), /*IsImplicit=*/true); - valueDRE->setType(valueParamDecl->getType()); + valueDRE->setType(valueParamDecl->getTypeInContext()); SmallVector setterBody; @@ -1817,7 +1817,7 @@ synthesizeObservedSetterBody(AccessorDecl *Set, TargetImpl target, DeclRefExpr *ValueDRE = nullptr; if (arg) { ValueDRE = new (Ctx) DeclRefExpr(arg, DeclNameLoc(), /*imp*/ true); - ValueDRE->setType(arg->getType()); + ValueDRE->setType(arg->getTypeInContext()); } if (SelfDecl) { @@ -1862,9 +1862,9 @@ synthesizeObservedSetterBody(AccessorDecl *Set, TargetImpl target, // Error recovery. if (OldValueExpr == nullptr) { - OldValueExpr = new (Ctx) ErrorExpr(SourceRange(), VD->getType()); + OldValueExpr = new (Ctx) ErrorExpr(SourceRange(), VD->getTypeInContext()); } else { - OldValueExpr = new (Ctx) LoadExpr(OldValueExpr, VD->getType()); + OldValueExpr = new (Ctx) LoadExpr(OldValueExpr, VD->getTypeInContext()); } OldValue = new (Ctx) VarDecl(/*IsStatic*/ false, VarDecl::Introducer::Let, @@ -1872,7 +1872,7 @@ synthesizeObservedSetterBody(AccessorDecl *Set, TargetImpl target, OldValue->setImplicit(); OldValue->setInterfaceType(VD->getValueInterfaceType()); auto *tmpPattern = - NamedPattern::createImplicit(Ctx, OldValue, OldValue->getType()); + NamedPattern::createImplicit(Ctx, OldValue, OldValue->getTypeInContext()); auto *tmpPBD = PatternBindingDecl::createImplicit( Ctx, StaticSpellingKind::None, tmpPattern, OldValueExpr, Set); SetterBody.push_back(tmpPBD); @@ -1885,7 +1885,7 @@ synthesizeObservedSetterBody(AccessorDecl *Set, TargetImpl target, // Create an assignment into the storage or call to superclass setter. auto *ValueDRE = new (Ctx) DeclRefExpr(ValueDecl, DeclNameLoc(), true); - ValueDRE->setType(ValueDecl->getType()); + ValueDRE->setType(ValueDecl->getTypeInContext()); createPropertyStoreOrCallSuperclassSetter( Set, ValueDRE, isLazy ? VD->getLazyStorageProperty() : VD, target, SetterBody, Ctx); @@ -2689,7 +2689,7 @@ LazyStoragePropertyRequest::evaluate(Evaluator &evaluator, NameBuf += VD->getName().str(); auto StorageName = Context.getIdentifier(NameBuf); auto StorageInterfaceTy = OptionalType::get(VD->getInterfaceType()); - auto StorageTy = OptionalType::get(VD->getType()); + auto StorageTy = OptionalType::get(VD->getTypeInContext()); auto *Storage = new (Context) VarDecl(/*IsStatic*/false, VarDecl::Introducer::Var, VD->getLoc(), StorageName, @@ -2711,7 +2711,7 @@ LazyStoragePropertyRequest::evaluate(Evaluator &evaluator, NamedPattern::createImplicit(Context, Storage, StorageTy); PBDPattern = TypedPattern::createImplicit(Context, PBDPattern, StorageTy); auto *InitExpr = new (Context) NilLiteralExpr(SourceLoc(), /*Implicit=*/true); - InitExpr->setType(Storage->getType()); + InitExpr->setType(Storage->getTypeInContext()); auto *PBD = PatternBindingDecl::createImplicit( Context, StaticSpellingKind::None, PBDPattern, InitExpr, @@ -3119,8 +3119,8 @@ PropertyWrapperInitializerInfoRequest::evaluate(Evaluator &evaluator, auto createPBD = [&](VarDecl *singleVar) -> PatternBindingDecl * { Pattern *pattern = - NamedPattern::createImplicit(ctx, singleVar, singleVar->getType()); - pattern = TypedPattern::createImplicit(ctx, pattern, singleVar->getType()); + NamedPattern::createImplicit(ctx, singleVar, singleVar->getTypeInContext()); + pattern = TypedPattern::createImplicit(ctx, pattern, singleVar->getTypeInContext()); PatternBindingDecl *pbd = PatternBindingDecl::createImplicit( ctx, var->getCorrectStaticSpelling(), pattern, /*init*/nullptr, dc, SourceLoc()); @@ -3211,7 +3211,7 @@ PropertyWrapperInitializerInfoRequest::evaluate(Evaluator &evaluator, // Projected-value initialization is currently only supported for parameters. auto *param = dyn_cast(var); auto *placeholder = PropertyWrapperValuePlaceholderExpr::create( - ctx, var->getSourceRange(), projection->getType(), /*projectedValue=*/nullptr); + ctx, var->getSourceRange(), projection->getTypeInContext(), /*projectedValue=*/nullptr); projectedValueInit = buildPropertyWrapperInitCall( var, storageType, placeholder, PropertyWrapperInitKind::ProjectedValue); TypeChecker::typeCheckExpression(projectedValueInit, dc); @@ -3233,7 +3233,7 @@ PropertyWrapperInitializerInfoRequest::evaluate(Evaluator &evaluator, var->allAttachedPropertyWrappersHaveWrappedValueInit() && !var->getName().hasDollarPrefix()) { wrappedValueInit = PropertyWrapperValuePlaceholderExpr::create( - ctx, var->getSourceRange(), var->getType(), /*wrappedValue=*/nullptr); + ctx, var->getSourceRange(), var->getTypeInContext(), /*wrappedValue=*/nullptr); typeCheckSynthesizedWrapperInitializer(var, wrappedValueInit, /*contextualize=*/true); } diff --git a/test/Constraints/result_builder_switch_with_vars.swift b/test/Constraints/result_builder_switch_with_vars.swift index 55af192c78b38..6fb9bc18760f3 100644 --- a/test/Constraints/result_builder_switch_with_vars.swift +++ b/test/Constraints/result_builder_switch_with_vars.swift @@ -49,8 +49,8 @@ func tuplify(@TupleBuilder body: (E) throws -> T) rethrows { tuplify { switch $0 { // CHECK: (case_body_variables - // CHECK-NEXT: (var_decl implicit {{.*}} "a" type='String' interface type='String' let readImpl=stored immutable) - // CHECK-NEXT: (var_decl implicit {{.*}} "b" type='Int' interface type='Int' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "a" interface type='String' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "b" interface type='Int' let readImpl=stored immutable) case let .test(a, b): a b @@ -58,8 +58,8 @@ tuplify { switch $0 { // CHECK: (case_body_variables - // CHECK-NEXT: (var_decl implicit {{.*}} "a" type='String' interface type='String' let readImpl=stored immutable) - // CHECK-NEXT: (var_decl implicit {{.*}} "b" type='Int' interface type='Int' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "a" interface type='String' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "b" interface type='Int' let readImpl=stored immutable) case .test(let a, let b): a b @@ -67,21 +67,21 @@ tuplify { switch $0 { // CHECK: (case_body_variables - // CHECK-NEXT: (var_decl implicit {{.*}} "value" type='(a: String, b: Int)' interface type='(a: String, b: Int)' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "value" interface type='(a: String, b: Int)' let readImpl=stored immutable) case let .test((value)): value.a } switch $0 { // CHECK: (case_body_variables - // CHECK-NEXT: (var_decl implicit {{.*}} "value" type='(a: String, b: Int)' interface type='(a: String, b: Int)' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "value" interface type='(a: String, b: Int)' let readImpl=stored immutable) case let .test(value): value.a } switch $0 { // CHECK: (case_body_variables - // CHECK-NEXT: (var_decl implicit {{.*}} "value" type='(a: String, b: Int)' interface type='(a: String, b: Int)' let readImpl=stored immutable) + // CHECK-NEXT: (var_decl implicit {{.*}} "value" interface type='(a: String, b: Int)' let readImpl=stored immutable) case .test(let value): value.a } diff --git a/test/Distributed/distributed_actor_executor_ast.swift b/test/Distributed/distributed_actor_executor_ast.swift index e1f3d17d9f997..1cdf281ca1ba5 100644 --- a/test/Distributed/distributed_actor_executor_ast.swift +++ b/test/Distributed/distributed_actor_executor_ast.swift @@ -27,7 +27,7 @@ distributed actor DefaultWorker { // Check DefaultWorker, the DefaultActor version of the synthesis: // CHECK: (class_decl range=[{{.*}}] "DefaultWorker" interface type='DefaultWorker.Type' access=internal non-resilient actor // The unowned executor property: -// CHECK: (var_decl implicit "unownedExecutor" type='UnownedSerialExecutor' interface type='UnownedSerialExecutor' access=internal final readImpl=getter immutable +// CHECK: (var_decl implicit "unownedExecutor" interface type='UnownedSerialExecutor' access=internal final readImpl=getter immutable // We guard the rest of the body; we only return a default executor if the actor is local: // CHECK: (guard_stmt implicit diff --git a/test/attr/attr_native_dynamic.swift b/test/attr/attr_native_dynamic.swift index c59ff8ea3eae6..54cae08b7e47b 100644 --- a/test/attr/attr_native_dynamic.swift +++ b/test/attr/attr_native_dynamic.swift @@ -2,19 +2,19 @@ struct Strukt { // CHECK: (struct_decl {{.*}} "Strukt" - // CHECK: (var_decl {{.*}} "dynamicStorageOnlyVar" type='Int' interface type='Int' access=internal dynamic readImpl=stored writeImpl=stored readWriteImpl=stored + // CHECK: (var_decl {{.*}} "dynamicStorageOnlyVar" interface type='Int' access=internal dynamic readImpl=stored writeImpl=stored readWriteImpl=stored // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=dynamicStorageOnlyVar // CHECK: (accessor_decl {{.*}} access=internal dynamic set_for=dynamicStorageOnlyVar // CHECK: (accessor_decl {{.*}} access=internal _modify_for=dynamicStorageOnlyVar dynamic var dynamicStorageOnlyVar : Int = 0 - // CHECK: (var_decl {{.*}} "computedVar" type='Int' interface type='Int' access=internal dynamic readImpl=getter immutable + // CHECK: (var_decl {{.*}} "computedVar" interface type='Int' access=internal dynamic readImpl=getter immutable // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVar dynamic var computedVar : Int { return 0 } - // CHECK: (var_decl {{.*}} "computedVar2" type='Int' interface type='Int' access=internal dynamic readImpl=getter immutable + // CHECK: (var_decl {{.*}} "computedVar2" interface type='Int' access=internal dynamic readImpl=getter immutable // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVar2 dynamic var computedVar2 : Int { get { @@ -22,7 +22,7 @@ struct Strukt { } } - // CHECK: (var_decl {{.*}} "computedVarGetterSetter" type='Int' interface type='Int' access=internal dynamic readImpl=getter writeImpl=setter readWriteImpl=materialize_to_temporary + // CHECK: (var_decl {{.*}} "computedVarGetterSetter" interface type='Int' access=internal dynamic readImpl=getter writeImpl=setter readWriteImpl=materialize_to_temporary // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVarGetterSetter // CHECK: (accessor_decl {{.*}} access=internal dynamic set_for=computedVarGetterSetter // CHECK: (accessor_decl {{.*}} access=internal _modify_for=computedVarGetterSetter @@ -34,7 +34,7 @@ struct Strukt { } } - // CHECK: (var_decl {{.*}} "computedVarGetterModify" type='Int' interface type='Int' access=internal dynamic readImpl=getter writeImpl=modify_coroutine readWriteImpl=modify_coroutine + // CHECK: (var_decl {{.*}} "computedVarGetterModify" interface type='Int' access=internal dynamic readImpl=getter writeImpl=modify_coroutine readWriteImpl=modify_coroutine // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVarGetterModify // CHECK: (accessor_decl {{.*}} access=internal dynamic _modify_for=computedVarGetterModify // CHECK: (accessor_decl {{.*}} access=internal set_for=computedVarGetterModify @@ -46,7 +46,7 @@ struct Strukt { } } - // CHECK: (var_decl {{.*}} "computedVarReadSet" type='Int' interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=setter readWriteImpl=materialize_to_temporary + // CHECK: (var_decl {{.*}} "computedVarReadSet" interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=setter readWriteImpl=materialize_to_temporary // CHECK: (accessor_decl {{.*}} access=internal dynamic _read_for=computedVarReadSet // CHECK: (accessor_decl {{.*}} access=internal dynamic set_for=computedVarReadSet // CHECK: (accessor_decl {{.*}} access=internal get_for=computedVarReadSet @@ -58,7 +58,7 @@ struct Strukt { } } - // CHECK: (var_decl {{.*}} "computedVarReadModify" type='Int' interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=modify_coroutine readWriteImpl=modify_coroutine + // CHECK: (var_decl {{.*}} "computedVarReadModify" interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=modify_coroutine readWriteImpl=modify_coroutine // CHECK: (accessor_decl {{.*}} access=internal dynamic _read_for=computedVarReadModify // CHECK: (accessor_decl {{.*}} access=internal dynamic _modify_for=computedVarReadModify // CHECK: (accessor_decl {{.*}} access=internal get_for=computedVarReadModify @@ -70,7 +70,7 @@ struct Strukt { } } - // CHECK: (var_decl {{.*}} "storedWithObserver" type='Int' interface type='Int' access=internal dynamic readImpl=stored writeImpl=stored_with_observers readWriteImpl=stored_with_didset + // CHECK: (var_decl {{.*}} "storedWithObserver" interface type='Int' access=internal dynamic readImpl=stored writeImpl=stored_with_observers readWriteImpl=stored_with_didset // CHECK: (accessor_decl {{.*}}access=private dynamic didSet_for=storedWithObserver // CHECK: (accessor_decl {{.*}}access=internal dynamic get_for=storedWithObserver // CHECK: (accessor_decl {{.*}}access=internal set_for=storedWithObserver @@ -136,19 +136,19 @@ struct Strukt { class Klass { // CHECK: (class_decl {{.*}} "Klass" - // CHECK: (var_decl {{.*}} "dynamicStorageOnlyVar" type='Int' interface type='Int' access=internal dynamic readImpl=stored writeImpl=stored readWriteImpl=stored + // CHECK: (var_decl {{.*}} "dynamicStorageOnlyVar" interface type='Int' access=internal dynamic readImpl=stored writeImpl=stored readWriteImpl=stored // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=dynamicStorageOnlyVar // CHECK: (accessor_decl {{.*}} access=internal dynamic set_for=dynamicStorageOnlyVar // CHECK: (accessor_decl {{.*}} access=internal _modify_for=dynamicStorageOnlyVar dynamic var dynamicStorageOnlyVar : Int = 0 - // CHECK: (var_decl {{.*}} "computedVar" type='Int' interface type='Int' access=internal dynamic readImpl=getter immutable + // CHECK: (var_decl {{.*}} "computedVar" interface type='Int' access=internal dynamic readImpl=getter immutable // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVar dynamic var computedVar : Int { return 0 } - // CHECK: (var_decl {{.*}} "computedVar2" type='Int' interface type='Int' access=internal dynamic readImpl=getter immutable + // CHECK: (var_decl {{.*}} "computedVar2" interface type='Int' access=internal dynamic readImpl=getter immutable // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVar2 dynamic var computedVar2 : Int { get { @@ -156,7 +156,7 @@ class Klass { } } - // CHECK: (var_decl {{.*}} "computedVarGetterSetter" type='Int' interface type='Int' access=internal dynamic readImpl=getter writeImpl=setter readWriteImpl=materialize_to_temporary + // CHECK: (var_decl {{.*}} "computedVarGetterSetter" interface type='Int' access=internal dynamic readImpl=getter writeImpl=setter readWriteImpl=materialize_to_temporary // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVarGetterSetter // CHECK: (accessor_decl {{.*}} access=internal dynamic set_for=computedVarGetterSetter // CHECK: (accessor_decl {{.*}} access=internal _modify_for=computedVarGetterSetter @@ -168,7 +168,7 @@ class Klass { } } - // CHECK: (var_decl {{.*}} "computedVarGetterModify" type='Int' interface type='Int' access=internal dynamic readImpl=getter writeImpl=modify_coroutine readWriteImpl=modify_coroutine + // CHECK: (var_decl {{.*}} "computedVarGetterModify" interface type='Int' access=internal dynamic readImpl=getter writeImpl=modify_coroutine readWriteImpl=modify_coroutine // CHECK: (accessor_decl {{.*}} access=internal dynamic get_for=computedVarGetterModify // CHECK: (accessor_decl {{.*}} access=internal dynamic _modify_for=computedVarGetterModify // CHECK: (accessor_decl {{.*}} access=internal set_for=computedVarGetterModify @@ -180,7 +180,7 @@ class Klass { } } - // CHECK: (var_decl {{.*}} "computedVarReadSet" type='Int' interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=setter readWriteImpl=materialize_to_temporary + // CHECK: (var_decl {{.*}} "computedVarReadSet" interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=setter readWriteImpl=materialize_to_temporary // CHECK: (accessor_decl {{.*}} access=internal dynamic _read_for=computedVarReadSet // CHECK: (accessor_decl {{.*}} access=internal dynamic set_for=computedVarReadSet // CHECK: (accessor_decl {{.*}} access=internal get_for=computedVarReadSet @@ -192,7 +192,7 @@ class Klass { } } - // CHECK: (var_decl {{.*}} "computedVarReadModify" type='Int' interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=modify_coroutine readWriteImpl=modify_coroutine + // CHECK: (var_decl {{.*}} "computedVarReadModify" interface type='Int' access=internal dynamic readImpl=read_coroutine writeImpl=modify_coroutine readWriteImpl=modify_coroutine // CHECK: (accessor_decl {{.*}} access=internal dynamic _read_for=computedVarReadModify // CHECK: (accessor_decl {{.*}} access=internal dynamic _modify_for=computedVarReadModify // CHECK: (accessor_decl {{.*}} access=internal get_for=computedVarReadModify