@@ -1170,14 +1170,19 @@ bool SILParser::performTypeLocChecking(TypeLoc &T, bool IsSILType,
1170
1170
1171
1171
// / Find the top-level ValueDecl or Module given a name.
1172
1172
static llvm::PointerUnion<ValueDecl *, ModuleDecl *>
1173
- lookupTopDecl (Parser &P, DeclBaseName Name) {
1173
+ lookupTopDecl (Parser &P, DeclBaseName Name, bool typeLookup ) {
1174
1174
// Use UnqualifiedLookup to look through all of the imports.
1175
1175
// We have to lie and say we're done with parsing to make this happen.
1176
1176
assert (P.SF .ASTStage == SourceFile::Parsing &&
1177
1177
" Unexpected stage during parsing!" );
1178
1178
llvm::SaveAndRestore<SourceFile::ASTStage_t> ASTStage (P.SF .ASTStage ,
1179
1179
SourceFile::Parsed);
1180
- UnqualifiedLookup DeclLookup (Name, &P.SF );
1180
+
1181
+ UnqualifiedLookup::Options options;
1182
+ if (typeLookup)
1183
+ options |= UnqualifiedLookup::Flags::TypeLookup;
1184
+
1185
+ UnqualifiedLookup DeclLookup (Name, &P.SF , SourceLoc (), options);
1181
1186
assert (DeclLookup.isSuccess () && DeclLookup.Results .size () == 1 );
1182
1187
ValueDecl *VD = DeclLookup.Results .back ().getValueDecl ();
1183
1188
return VD;
@@ -1358,9 +1363,11 @@ bool SILParser::parseSILDottedPathWithoutPound(ValueDecl *&Decl,
1358
1363
}
1359
1364
} while (P.consumeIf (tok::period));
1360
1365
1361
- // Look up ValueDecl from a dotted path.
1366
+ // Look up ValueDecl from a dotted path. If there are multiple components,
1367
+ // the first one must be a type declaration.
1362
1368
ValueDecl *VD;
1363
- llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res = lookupTopDecl (P, FullName[0 ]);
1369
+ llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res = lookupTopDecl (
1370
+ P, FullName[0 ], /* typeLookup=*/ FullName.size () > 1 );
1364
1371
// It is possible that the last member lookup can return multiple lookup
1365
1372
// results. One example is the overloaded member functions.
1366
1373
if (Res.is <ModuleDecl*>()) {
@@ -5748,7 +5755,8 @@ bool SILParserTUState::parseSILVTable(Parser &P) {
5748
5755
return true ;
5749
5756
5750
5757
// Find the class decl.
5751
- llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res = lookupTopDecl (P, Name);
5758
+ llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res =
5759
+ lookupTopDecl (P, Name, /* typeLookup=*/ true );
5752
5760
assert (Res.is <ValueDecl*>() && " Class look-up should return a Decl" );
5753
5761
ValueDecl *VD = Res.get <ValueDecl*>();
5754
5762
if (!VD) {
@@ -5835,7 +5843,8 @@ static ProtocolDecl *parseProtocolDecl(Parser &P, SILParser &SP) {
5835
5843
return nullptr ;
5836
5844
5837
5845
// Find the protocol decl. The protocol can be imported.
5838
- llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res = lookupTopDecl (P, DeclName);
5846
+ llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res =
5847
+ lookupTopDecl (P, DeclName, /* typeLookup=*/ true );
5839
5848
assert (Res.is <ValueDecl*>() && " Protocol look-up should return a Decl" );
5840
5849
ValueDecl *VD = Res.get <ValueDecl*>();
5841
5850
if (!VD) {
0 commit comments