@@ -6846,25 +6846,6 @@ void TypeChecker::checkDeclCircularity(NominalTypeDecl *decl) {
68466846 }
68476847}
68486848
6849- // / Determine whether the given variable is the implicit 'self' parameter for
6850- // / a function, and return that function if so.
6851- static AbstractFunctionDecl *isImplicitSelfParam (VarDecl *var){
6852- if (!var->isImplicit ()) return nullptr ;
6853-
6854- auto param = dyn_cast<ParamDecl>(var);
6855- if (!param) return nullptr ;
6856-
6857- auto func = dyn_cast<AbstractFunctionDecl>(var->getDeclContext ());
6858- if (!func) return nullptr ;
6859-
6860- if (!func->getDeclContext ()->isTypeContext ()) return nullptr ;
6861-
6862- if (param == func->getImplicitSelfDecl ())
6863- return func;
6864-
6865- return nullptr ;
6866- }
6867-
68686849void TypeChecker::validateDecl (ValueDecl *D, bool resolveTypeParams) {
68696850 if (hasEnabledForbiddenTypecheckPrefix ())
68706851 checkForForbiddenPrefix (D);
@@ -7112,12 +7093,12 @@ void TypeChecker::validateDecl(ValueDecl *D, bool resolveTypeParams) {
71127093 case DeclKind::Param: {
71137094 auto VD = cast<VarDecl>(D);
71147095 if (!VD->hasType ()) {
7115- if (auto func = isImplicitSelfParam (VD )) {
7096+ if (VD-> isSelfParameter ( )) {
71167097 if (!VD->hasInterfaceType ()) {
71177098 VD->setInterfaceType (ErrorType::get (Context));
71187099 VD->setInvalid ();
71197100 }
7120- recordSelfContextType (func );
7101+ recordSelfContextType (cast<AbstractFunctionDecl>(VD-> getDeclContext ()) );
71217102 } else if (PatternBindingDecl *PBD = VD->getParentPatternBinding ()) {
71227103 if (PBD->isBeingTypeChecked ()) {
71237104 diagnose (VD, diag::pattern_used_in_type, VD->getName ());
0 commit comments