Eliminate some pointless uses of the doomed DeclContext::getSelfTypeInContext()

This commit is contained in:
Doug Gregor
2016-12-02 09:12:40 -08:00
parent 6fffae7517
commit 18aa7104da
4 changed files with 8 additions and 15 deletions

View File

@@ -1331,13 +1331,7 @@ void TypeChecker::completePropertyBehaviorParameter(VarDecl *VD,
// Borrow the parameters from the requirement declaration.
SmallVector<ParameterList *, 2> ParamLists;
if (DC->isTypeContext()) {
auto self = new (Context) ParamDecl(/*let*/ true, SourceLoc(), SourceLoc(),
Identifier(), SourceLoc(),
Context.Id_self,
DC->getSelfTypeInContext(), DC);
self->setInterfaceType(DC->getSelfInterfaceType());
self->setImplicit();
auto self = ParamDecl::createSelf(SourceLoc(), DC);
ParamLists.push_back(ParameterList::create(Context, SourceLoc(),
self, SourceLoc()));
ParamLists.back()->get(0)->setImplicit();

View File

@@ -4616,6 +4616,7 @@ public:
if (!selfNominal) return;
// Check the parameters for a reference to 'Self'.
auto genericEnv = FD->getGenericEnvironment();
bool isProtocol = isa<ProtocolDecl>(selfNominal);
for (auto param : *FD->getParameterList(1)) {
auto paramType = param->getType();
@@ -4623,7 +4624,10 @@ public:
// Look through 'inout'.
paramType = paramType->getInOutObjectType();
if (genericEnv) {
paramType = genericEnv->mapTypeOutOfContext(FD->getModuleContext(),
paramType);
}
// Look through a metatype reference, if there is one.
if (auto metatypeType = paramType->getAs<AnyMetatypeType>())
paramType = metatypeType->getInstanceType();
@@ -4636,11 +4640,6 @@ public:
if (auto genericParam = paramType->getAs<GenericTypeParamType>())
if (genericParam->isEqual(DC->getSelfInterfaceType()))
return;
// ... or the 'Self' archetype?
if (auto archetype = paramType->getAs<ArchetypeType>())
if (archetype->isEqual(DC->getSelfTypeInContext()))
return;
}
}

View File

@@ -2392,7 +2392,7 @@ static void diagnoseNoWitness(ValueDecl *Requirement, Type RequirementType,
Options.AccessibilityFilter = Accessibility::Private;
Options.PrintAccessibility = false;
Options.FunctionBody = [](const ValueDecl *VD) { return "<#code#>"; };
Options.setBaseType(Adopter->getSelfTypeInContext());
Options.setBaseType(Conformance->getType());
Options.CurrentModule = Adopter->getParentModule();
if (!Adopter->isExtensionContext()) {
// Create a variable declaration instead of a computed property in

View File

@@ -942,7 +942,7 @@ resolveTopLevelIdentTypeComponent(TypeChecker &TC, DeclContext *DC,
// while the 'Self' type is more than just a reference to a TypeDecl.
return DynamicSelfType::get(
func->getDeclContext()->getSelfTypeInContext(),
func->computeSelfType()->getRValueInstanceType(),
TC.Context);
}