Skip to content

Remove a couple of calls to hasComputedGenericSignature() #37662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/Sema/MiscDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1840,13 +1840,9 @@ bool TypeChecker::getDefaultGenericArgumentsString(
genericParamText << contextTy;
};

// FIXME: We can potentially be in the middle of creating a generic signature
// if we get here. Break this cycle.
if (typeDecl->hasComputedGenericSignature()) {
llvm::interleave(typeDecl->getInnermostGenericParamTypes(),
printGenericParamSummary,
[&] { genericParamText << ", "; });
}
llvm::interleave(typeDecl->getInnermostGenericParamTypes(),
printGenericParamSummary,
[&] { genericParamText << ", "; });

genericParamText << ">";
return true;
Expand Down
7 changes: 0 additions & 7 deletions lib/Sema/TypeCheckProtocolInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,6 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
// declared on, it is viable for inference when its conditional
// requirements are satisfied by those of the conformance context.
if (!proto) {
// FIXME: The extension may not have a generic signature set up yet as
// resolving signatures may trigger associated type inference. This cycle
// is now detectable and we should look into untangling it
// - see rdar://55263708
if (!extension->hasComputedGenericSignature())
return true;

// Retrieve the generic signature of the extension.
const auto extensionSig = extension->getGenericSignature();

Expand Down
14 changes: 10 additions & 4 deletions lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,11 +996,17 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc) {
if (auto unbound = ty->getAs<UnboundGenericType>()) {
auto *decl = unbound->getDecl();
{
InFlightDiagnostic diag = ctx.Diags.diagnose(loc,
diag::generic_type_requires_arguments, ty);
// Compute the string before creating a new diagnostic, since
// getDefaultGenericArgumentsString() might emit its own
// diagnostics.
SmallString<64> genericArgsToAdd;
if (TypeChecker::getDefaultGenericArgumentsString(genericArgsToAdd,
decl))
bool hasGenericArgsToAdd =
TypeChecker::getDefaultGenericArgumentsString(genericArgsToAdd,
decl);

auto diag = ctx.Diags.diagnose(loc,
diag::generic_type_requires_arguments, ty);
if (hasGenericArgsToAdd)
diag.fixItInsertAfter(loc, genericArgsToAdd);
}

Expand Down