@@ -273,11 +273,6 @@ class ScopeCreator final {
273273 // Implicit nodes may not have source information for name lookup.
274274 if (!isLocalizable (d))
275275 return false ;
276- // / In \c Parser::parseDeclVarGetSet fake PBDs are created. Ignore them.
277- // / Example:
278- // / \code
279- // / class SR10903 { static var _: Int { 0 } }
280- // / \endcode
281276
282277 // Commented out for
283278 // validation-test/compiler_crashers_fixed/27962-swift-rebindselfinconstructorexpr-getcalledconstructor.swift
@@ -502,9 +497,6 @@ class ScopeCreator final {
502497 std::vector<ASTNode> expandIfConfigClausesThenCullAndSortElementsOrMembers (
503498 ArrayRef<ASTNode> input) const {
504499 auto cleanedupNodes = sortBySourceRange (cull (expandIfConfigClauses (input)));
505- // TODO: uncomment when working on not creating two pattern binding decls at
506- // same location.
507- // findCollidingPatterns(cleanedupNodes);
508500 return cleanedupNodes;
509501 }
510502
@@ -562,73 +554,6 @@ class ScopeCreator final {
562554 return culled;
563555 }
564556
565- // / TODO: The parser yields two decls at the same source loc with the same
566- // / kind. TODO: me when fixing parser's proclivity to create two
567- // / PatternBindingDecls at the same source location, then move this to
568- // / ASTVerifier.
569- // /
570- // / In all cases the first pattern seems to carry the initializer, and the
571- // / second, the accessor
572- void findCollidingPatterns (ArrayRef<ASTNode> input) const {
573- auto dumpPBD = [&](PatternBindingDecl *pbd, const char *which) {
574- llvm::errs () << " *** " << which
575- << " pbd isImplicit: " << pbd->isImplicit ()
576- << " , #entries: " << pbd->getNumPatternEntries () << " :" ;
577- pbd->getSourceRange ().print (llvm::errs (), pbd->getASTContext ().SourceMgr ,
578- false );
579- llvm::errs () << " \n " ;
580- llvm::errs () << " init: " << pbd->getInit (0 ) << " \n " ;
581- if (pbd->getInit (0 )) {
582- llvm::errs () << " SR (init): " ;
583- pbd->getInit (0 )->getSourceRange ().print (
584- llvm::errs (), pbd->getASTContext ().SourceMgr , false );
585- llvm::errs () << " \n " ;
586- pbd->getInit (0 )->dump (llvm::errs (), 0 );
587- }
588- llvm::errs () << " vars:\n " ;
589- pbd->getPattern (0 )->forEachVariable ([&](VarDecl *vd) {
590- llvm::errs () << " " << vd->getName ()
591- << " implicit: " << vd->isImplicit ()
592- << " #accs: " << vd->getAllAccessors ().size ()
593- << " \n SR (var):" ;
594- vd->getSourceRange ().print (llvm::errs (), pbd->getASTContext ().SourceMgr ,
595- false );
596- llvm::errs () << " \n SR (braces)" ;
597- vd->getBracesRange ().print (llvm::errs (), pbd->getASTContext ().SourceMgr ,
598- false );
599- llvm::errs () << " \n " ;
600- for (auto *a : vd->getAllAccessors ()) {
601- llvm::errs () << " SR (acc): " ;
602- a->getSourceRange ().print (llvm::errs (),
603- pbd->getASTContext ().SourceMgr , false );
604- llvm::errs () << " \n " ;
605- a->dump (llvm::errs (), 0 );
606- }
607- });
608- };
609-
610- Decl *lastD = nullptr ;
611- for (auto n : input) {
612- auto *d = n.dyn_cast <Decl *>();
613- if (!d || !lastD || lastD->getStartLoc () != d->getStartLoc () ||
614- lastD->getKind () != d->getKind ()) {
615- lastD = d;
616- continue ;
617- }
618- if (auto *pbd = dyn_cast<PatternBindingDecl>(lastD))
619- dumpPBD (pbd, " prev" );
620- if (auto *pbd = dyn_cast<PatternBindingDecl>(d)) {
621- dumpPBD (pbd, " curr" );
622- ASTScope_unreachable (" found colliding pattern binding decls" );
623- }
624- llvm::errs () << " Two same kind decls at same loc: \n " ;
625- lastD->dump (llvm::errs ());
626- llvm::errs () << " and\n " ;
627- d->dump (llvm::errs ());
628- ASTScope_unreachable (" Two same kind decls; unexpected kinds" );
629- }
630- }
631-
632557 // / Templated to work on either ASTNodes, Decl*'s, or whatnot.
633558 template <typename Rangeable>
634559 std::vector<Rangeable>
@@ -962,24 +887,6 @@ class NodeAdder
962887 : DeclVisibilityKind::LocalVariable;
963888 auto *insertionPoint = parentScope;
964889 for (auto i : range (patternBinding->getNumPatternEntries ())) {
965- // TODO: Won't need to do so much work to avoid creating one without
966- // a SourceRange once parser is fixed to not create two
967- // PatternBindingDecls with same locaiton and getSourceRangeOfThisASTNode
968- // for PatternEntryDeclScope is simplified to use the PatternEntry's
969- // source range.
970- if (!patternBinding->getOriginalInit (i)) {
971- bool found = false ;
972- patternBinding->getPattern (i)->forEachVariable ([&](VarDecl *vd) {
973- if (!vd->isImplicit ())
974- found = true ;
975- else
976- found |= llvm::any_of (vd->getAllAccessors (), [&](AccessorDecl *a) {
977- return isLocalizable (a);
978- });
979- });
980- if (!found)
981- continue ;
982- }
983890 insertionPoint =
984891 scopeCreator
985892 .ifUniqueConstructExpandAndInsert <PatternEntryDeclScope>(
0 commit comments