Skip to content

Commit ead8fd1

Browse files
committed
Sema: diagnoseUnknownType() should use AST name lookup
This avoids cycles where type checker name lookup used a LookupResultBuilder, which could try to get a GenericSignatureBuilder for the signature currently being built. This fixes some cycles when the requirement machine is enabled.
1 parent dd543e6 commit ead8fd1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,18 +1261,17 @@ static Type diagnoseUnknownType(TypeResolution resolution,
12611261
comp->getNameRef(), moduleType->getModule()->getName());
12621262
} else {
12631263
LookupResult memberLookup;
1264-
// Let's try to lookup given identifier as a member of the parent type,
1265-
// this allows for more precise diagnostic, which distinguishes between
1266-
// identifier not found as a member type vs. not found at all.
1267-
NameLookupOptions memberLookupOptions = lookupOptions;
1268-
memberLookupOptions |= NameLookupFlags::IgnoreAccessControl;
1269-
memberLookup = TypeChecker::lookupMember(dc, parentType,
1270-
comp->getNameRef(),
1271-
memberLookupOptions);
1264+
// Let's try to look any member of the parent type with the given name,
1265+
// even if it is not a type, allowing for a more precise diagnostic.
1266+
NLOptions memberLookupOptions = (NL_QualifiedDefault |
1267+
NL_IgnoreAccessControl);
1268+
SmallVector<ValueDecl *, 2> results;
1269+
dc->lookupQualified(parentType, comp->getNameRef(), memberLookupOptions,
1270+
results);
12721271

12731272
// Looks like this is not a member type, but simply a member of parent type.
1274-
if (!memberLookup.empty()) {
1275-
auto member = memberLookup[0].getValueDecl();
1273+
if (!results.empty()) {
1274+
auto member = results[0];
12761275
diags.diagnose(comp->getNameLoc(), diag::invalid_member_reference,
12771276
member->getDescriptiveKind(), member->getName(),
12781277
parentType)

0 commit comments

Comments
 (0)