@@ -1882,27 +1882,18 @@ PatternBindingDecl::create(ASTContext &Ctx, SourceLoc StaticLoc,
1882
1882
StaticSpellingKind StaticSpelling, SourceLoc VarLoc,
1883
1883
Pattern *Pat, SourceLoc EqualLoc, Expr *E,
1884
1884
DeclContext *Parent) {
1885
- DeclContext *BindingInitContext = nullptr ;
1886
- if (!Parent->isLocalContext ())
1887
- BindingInitContext = new (Ctx) PatternBindingInitializer (Parent);
1888
-
1889
- auto PBE = PatternBindingEntry (Pat, EqualLoc, E, BindingInitContext);
1890
- auto *Result = create (Ctx, StaticLoc, StaticSpelling, VarLoc, PBE, Parent);
1891
-
1892
- if (BindingInitContext)
1893
- cast<PatternBindingInitializer>(BindingInitContext)->setBinding (Result, 0 );
1894
-
1895
- return Result;
1885
+ // We can provide a null context, 'create' will fill it in for us.
1886
+ // FIXME: This seems dubious, see the comment in 'create'.
1887
+ auto PBE = PatternBindingEntry (Pat, EqualLoc, E, /* InitContext*/ nullptr );
1888
+ return create (Ctx, StaticLoc, StaticSpelling, VarLoc, PBE, Parent);
1896
1889
}
1897
1890
1898
1891
PatternBindingDecl *PatternBindingDecl::createImplicit (
1899
1892
ASTContext &Ctx, StaticSpellingKind StaticSpelling, Pattern *Pat, Expr *E,
1900
1893
DeclContext *Parent, SourceLoc VarLoc) {
1901
1894
auto *Result = create (Ctx, /* StaticLoc*/ SourceLoc (), StaticSpelling, VarLoc,
1902
- Pat, /* EqualLoc*/ SourceLoc (), nullptr , Parent);
1895
+ Pat, /* EqualLoc*/ SourceLoc (), E , Parent);
1903
1896
Result->setImplicit ();
1904
- Result->setInit (0 , E);
1905
- Result->setOriginalInit (0 , E);
1906
1897
return Result;
1907
1898
}
1908
1899
@@ -1937,6 +1928,10 @@ PatternBindingDecl::create(ASTContext &Ctx, SourceLoc StaticLoc,
1937
1928
auto &newEntry = entries[elt];
1938
1929
newEntry = pe; // This should take care of initializer with flags
1939
1930
DeclContext *initContext = pe.getInitContext ();
1931
+
1932
+ // FIXME: We ought to reconsider this since it won't recontextualize any
1933
+ // closures/decls present in the initialization expr. This currently should
1934
+ // only affect implicit code though.
1940
1935
if (!initContext && !Parent->isLocalContext ()) {
1941
1936
auto pbi = new (Ctx) PatternBindingInitializer (Parent);
1942
1937
pbi->setBinding (PBD, elt);
0 commit comments