Skip to content

Commit 6efd419

Browse files
authored
Merge pull request #37662 from slavapestov/remove-circularity-hacks
Remove a couple of calls to hasComputedGenericSignature()
2 parents 672d5aa + 5bdf189 commit 6efd419

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,13 +1840,9 @@ bool TypeChecker::getDefaultGenericArgumentsString(
18401840
genericParamText << contextTy;
18411841
};
18421842

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

18511847
genericParamText << ">";
18521848
return true;

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,6 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
213213
// declared on, it is viable for inference when its conditional
214214
// requirements are satisfied by those of the conformance context.
215215
if (!proto) {
216-
// FIXME: The extension may not have a generic signature set up yet as
217-
// resolving signatures may trigger associated type inference. This cycle
218-
// is now detectable and we should look into untangling it
219-
// - see rdar://55263708
220-
if (!extension->hasComputedGenericSignature())
221-
return true;
222-
223216
// Retrieve the generic signature of the extension.
224217
const auto extensionSig = extension->getGenericSignature();
225218

lib/Sema/TypeCheckType.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,17 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc) {
996996
if (auto unbound = ty->getAs<UnboundGenericType>()) {
997997
auto *decl = unbound->getDecl();
998998
{
999-
InFlightDiagnostic diag = ctx.Diags.diagnose(loc,
1000-
diag::generic_type_requires_arguments, ty);
999+
// Compute the string before creating a new diagnostic, since
1000+
// getDefaultGenericArgumentsString() might emit its own
1001+
// diagnostics.
10011002
SmallString<64> genericArgsToAdd;
1002-
if (TypeChecker::getDefaultGenericArgumentsString(genericArgsToAdd,
1003-
decl))
1003+
bool hasGenericArgsToAdd =
1004+
TypeChecker::getDefaultGenericArgumentsString(genericArgsToAdd,
1005+
decl);
1006+
1007+
auto diag = ctx.Diags.diagnose(loc,
1008+
diag::generic_type_requires_arguments, ty);
1009+
if (hasGenericArgsToAdd)
10041010
diag.fixItInsertAfter(loc, genericArgsToAdd);
10051011
}
10061012

0 commit comments

Comments
 (0)