Skip to content

Commit c3bbe64

Browse files
committed
Code cleanups based @slavapestov's review
1 parent e05dee1 commit c3bbe64

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,6 @@ ReabstractionInfo::createSubstitutedType(SILFunction *OrigF,
231231
FnTy->getOptionalErrorResult(), M.getASTContext());
232232

233233
// This is an interface type. It should not have any archetypes.
234-
if (NewFnTy->hasArchetype()) {
235-
NewFnTy->dump();
236-
}
237234
assert(!NewFnTy->hasArchetype());
238235
return NewFnTy;
239236
}
@@ -320,13 +317,10 @@ checkSpecializationRequirements(ArrayRef<Requirement> Requirements) {
320317
auto FirstType = Req.getFirstType();
321318
auto SecondType = Req.getSecondType();
322319
assert(FirstType && SecondType);
323-
324-
bool isFirstTypeNonConcrete =
325-
FirstType->hasArchetype() || FirstType->hasTypeParameter();
326-
bool isSecondTypeNonConcrete =
327-
SecondType->hasArchetype() || SecondType->hasTypeParameter();
320+
assert(!FirstType->hasArchetype());
321+
assert(!SecondType->hasArchetype());
328322
// Only one of the types should be concrete.
329-
assert((isFirstTypeNonConcrete ^ isSecondTypeNonConcrete) &&
323+
assert(FirstType->hasTypeParameter() != SecondType->hasTypeParameter() &&
330324
"Only concrete type same-type requirements are supported by "
331325
"generic specialization");
332326
continue;
@@ -372,7 +366,7 @@ ReabstractionInfo::ReabstractionInfo(SILFunction *OrigF,
372366

373367
for (auto &Req : Requirements) {
374368
if (Req.getKind() == RequirementKind::SameType) {
375-
auto CallerArchetype = dyn_cast<SubstitutableType>(
369+
auto CallerArchetype = cast<SubstitutableType>(
376370
OrigGenericEnv->mapTypeIntoContext(Req.getFirstType())
377371
->getCanonicalType());
378372
// Remember that a given generic parameter is mapped
@@ -398,7 +392,7 @@ ReabstractionInfo::ReabstractionInfo(SILFunction *OrigF,
398392
// Remember how the original contextual type is represented in
399393
// the specialized function.
400394
if (Req.getKind() == RequirementKind::Layout) {
401-
auto CallerArchetype = dyn_cast<SubstitutableType>(
395+
auto CallerArchetype = cast<SubstitutableType>(
402396
OrigGenericEnv->mapTypeIntoContext(Req.getFirstType())
403397
->getCanonicalType());
404398

@@ -417,7 +411,7 @@ ReabstractionInfo::ReabstractionInfo(SILFunction *OrigF,
417411
// the caller archetypes to their interface types or the corresponding
418412
// archetypes in the specialized function.
419413
for (auto GP : SpecializedGenericSig->getGenericParams()) {
420-
auto CallerArchetype = dyn_cast<SubstitutableType>(
414+
auto CallerArchetype = cast<SubstitutableType>(
421415
OrigGenericEnv->mapTypeIntoContext(GP)->getCanonicalType());
422416
if (CallerArchetypeToInterfaceMap.lookupSubstitution(CallerArchetype))
423417
continue;
@@ -437,6 +431,8 @@ ReabstractionInfo::ReabstractionInfo(SILFunction *OrigF,
437431
SmallVector<Substitution, 4> ClonerSubsList;
438432
SmallVector<Substitution, 4> CallerSubsList;
439433
SmallVector<Substitution, 4> InterfaceCallerSubsList;
434+
// FIXME: Clean up the module conformance lookup currently used by subst()
435+
// calls. They should not directly use module conformance lookup here.
440436
for (auto Sub : ForwardingSubs) {
441437
auto ClonerSub = Sub.subst(
442438
SM, QuerySubstitutionMap{ClonerArchetypeToConcreteMap},

0 commit comments

Comments
 (0)