@@ -43,9 +43,6 @@ using namespace ide;
4343// ===----------------------------------------------------------------------===//
4444
4545void swift::ide::typeCheckContextAt (DeclContext *DC, SourceLoc Loc) {
46- while (isa<AbstractClosureExpr>(DC))
47- DC = DC->getParent ();
48-
4946 // Make sure the extension has been bound.
5047 {
5148 // Even if the extension is invalid (e.g. nested in a function or another
@@ -77,60 +74,7 @@ void swift::ide::typeCheckContextAt(DeclContext *DC, SourceLoc Loc) {
7774 }
7875 }
7976
80- // Type-check this context.
81- switch (DC->getContextKind ()) {
82- case DeclContextKind::AbstractClosureExpr:
83- case DeclContextKind::Module:
84- case DeclContextKind::FileUnit:
85- case DeclContextKind::SerializedLocal:
86- case DeclContextKind::EnumElementDecl:
87- case DeclContextKind::GenericTypeDecl:
88- case DeclContextKind::SubscriptDecl:
89- case DeclContextKind::ExtensionDecl:
90- // Nothing to do for these.
91- break ;
92-
93- case DeclContextKind::Initializer:
94- if (auto *patternInit = dyn_cast<PatternBindingInitializer>(DC)) {
95- if (auto *PBD = patternInit->getBinding ()) {
96- auto i = patternInit->getBindingIndex ();
97- PBD->getPattern (i)->forEachVariable (
98- [](VarDecl *VD) { (void )VD->getInterfaceType (); });
99- if (PBD->getInit (i)) {
100- if (!PBD->isInitializerChecked (i))
101- typeCheckPatternBinding (PBD, i,
102- /* LeaveClosureBodyUnchecked=*/ true );
103- }
104- }
105- } else if (auto *defaultArg = dyn_cast<DefaultArgumentInitializer>(DC)) {
106- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(defaultArg->getParent ())) {
107- auto *Param = AFD->getParameters ()->get (defaultArg->getIndex ());
108- (void )Param->getTypeCheckedDefaultExpr ();
109- }
110- if (auto *SD = dyn_cast<SubscriptDecl>(defaultArg->getParent ())) {
111- auto *Param = SD->getIndices ()->get (defaultArg->getIndex ());
112- (void )Param->getTypeCheckedDefaultExpr ();
113- }
114- }
115- break ;
116-
117- case DeclContextKind::TopLevelCodeDecl:
118- swift::typeCheckASTNodeAtLoc (DC, Loc);
119- break ;
120-
121- case DeclContextKind::AbstractFunctionDecl: {
122- auto *AFD = cast<AbstractFunctionDecl>(DC);
123- auto &SM = DC->getASTContext ().SourceMgr ;
124- auto bodyRange = AFD->getBodySourceRange ();
125- if (SM.rangeContainsTokenLoc (bodyRange, Loc)) {
126- swift::typeCheckASTNodeAtLoc (DC, Loc);
127- } else {
128- assert (bodyRange.isInvalid () && " The body should not be parsed if the "
129- " completion happens in the signature" );
130- }
131- break ;
132- }
133- }
77+ swift::typeCheckASTNodeAtLoc (DC, Loc);
13478}
13579
13680// ===----------------------------------------------------------------------===//
0 commit comments