@@ -357,15 +357,15 @@ LayoutConstraint GenericSignatureImpl::getLayoutConstraint(Type type) const {
357357 return getRequirementMachine ()->getLayoutConstraint (type);
358358}
359359
360- bool GenericSignatureImpl::areSameTypeParameterInContext (Type type1,
360+ bool GenericSignatureImpl::areReducedTypeParametersEqual (Type type1,
361361 Type type2) const {
362362 assert (type1->isTypeParameter ());
363363 assert (type2->isTypeParameter ());
364364
365365 if (type1.getPointer () == type2.getPointer ())
366366 return true ;
367367
368- return getRequirementMachine ()->areSameTypeParameterInContext (type1, type2);
368+ return getRequirementMachine ()->areReducedTypeParametersEqual (type1, type2);
369369}
370370
371371bool GenericSignatureImpl::isRequirementSatisfied (
@@ -431,43 +431,40 @@ SmallVector<Requirement, 4> GenericSignatureImpl::requirementsNotSatisfiedBy(
431431 return result;
432432}
433433
434- bool GenericSignatureImpl::isCanonicalTypeInContext (Type type) const {
435- // If the type isn't independently canonical, it's certainly not canonical
436- // in this context.
434+ bool GenericSignatureImpl::isReducedType (Type type) const {
435+ // If the type isn't canonical, it's not reduced.
437436 if (!type->isCanonical ())
438437 return false ;
439438
440- // All the contextual canonicality rules apply to type parameters, so if the
441- // type doesn't involve any type parameters, it's already canonical.
439+ // A fully concrete canonical type is reduced.
442440 if (!type->hasTypeParameter ())
443441 return true ;
444442
445- return getRequirementMachine ()->isCanonicalTypeInContext (type);
443+ return getRequirementMachine ()->isReducedType (type);
446444}
447445
448- CanType GenericSignature::getCanonicalTypeInContext (Type type) const {
446+ CanType GenericSignature::getReducedType (Type type) const {
449447 // The null generic signature has no requirements so cannot influence the
450448 // structure of the can type computed here.
451449 if (isNull ()) {
452450 return type->getCanonicalType ();
453451 }
454- return getPointer ()->getCanonicalTypeInContext (type);
452+ return getPointer ()->getReducedType (type);
455453}
456454
457- CanType GenericSignatureImpl::getCanonicalTypeInContext (Type type) const {
455+ CanType GenericSignatureImpl::getReducedType (Type type) const {
458456 type = type->getCanonicalType ();
459457
460- // All the contextual canonicality rules apply to type parameters, so if the
461- // type doesn't involve any type parameters, it's already canonical.
458+ // A fully concrete type is already reduced.
462459 if (!type->hasTypeParameter ())
463460 return CanType (type);
464461
465- return getRequirementMachine ()->getCanonicalTypeInContext (
462+ return getRequirementMachine ()->getReducedType (
466463 type, { })->getCanonicalType ();
467464}
468465
469- bool GenericSignatureImpl::isValidTypeInContext (Type type) const {
470- return getRequirementMachine ()->isValidTypeInContext (type);
466+ bool GenericSignatureImpl::isValidTypeParameter (Type type) const {
467+ return getRequirementMachine ()->isValidTypeParameter (type);
471468}
472469
473470ArrayRef<CanTypeWrapper<GenericTypeParamType>>
@@ -850,8 +847,8 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
850847 abort ();
851848 }
852849
853- if (!canSig->isCanonicalTypeInContext (reqt.getFirstType ())) {
854- llvm::errs () << " Left-hand side is not canonical : " ;
850+ if (!canSig->isReducedType (reqt.getFirstType ())) {
851+ llvm::errs () << " Left-hand side is not reduced : " ;
855852 reqt.dump (llvm::errs ());
856853 llvm::errs () << " \n " ;
857854 abort ();
@@ -861,8 +858,8 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
861858 // Check canonicalization of requirement itself.
862859 switch (reqt.getKind ()) {
863860 case RequirementKind::Superclass:
864- if (!canSig->isCanonicalTypeInContext (reqt.getSecondType ())) {
865- llvm::errs () << " Right-hand side is not canonical : " ;
861+ if (!canSig->isReducedType (reqt.getSecondType ())) {
862+ llvm::errs () << " Right-hand side is not reduced : " ;
866863 reqt.dump (llvm::errs ());
867864 llvm::errs () << " \n " ;
868865 abort ();
@@ -873,9 +870,9 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
873870 break ;
874871
875872 case RequirementKind::SameType: {
876- auto hasCanonicalOrConcreteParent = [&](Type type) {
873+ auto hasReducedOrConcreteParent = [&](Type type) {
877874 if (auto *dmt = type->getAs <DependentMemberType>()) {
878- return (canSig->isCanonicalTypeInContext (dmt->getBase ()) ||
875+ return (canSig->isReducedType (dmt->getBase ()) ||
879876 canSig->isConcreteType (dmt->getBase ()));
880877 }
881878 return type->is <GenericTypeParamType>();
@@ -884,19 +881,19 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
884881 auto firstType = reqt.getFirstType ();
885882 auto secondType = reqt.getSecondType ();
886883
887- auto canType = canSig->getCanonicalTypeInContext (firstType);
884+ auto canType = canSig->getReducedType (firstType);
888885 auto &component = sameTypeComponents[canType];
889886
890- if (!hasCanonicalOrConcreteParent (firstType)) {
891- llvm::errs () << " Left hand side does not have a canonical parent: " ;
887+ if (!hasReducedOrConcreteParent (firstType)) {
888+ llvm::errs () << " Left hand side does not have a reduced parent: " ;
892889 reqt.dump (llvm::errs ());
893890 llvm::errs () << " \n " ;
894891 abort ();
895892 }
896893
897894 if (reqt.getSecondType ()->isTypeParameter ()) {
898- if (!hasCanonicalOrConcreteParent (secondType)) {
899- llvm::errs () << " Right hand side does not have a canonical parent: " ;
895+ if (!hasReducedOrConcreteParent (secondType)) {
896+ llvm::errs () << " Right hand side does not have a reduced parent: " ;
900897 reqt.dump (llvm::errs ());
901898 llvm::errs () << " \n " ;
902899 abort ();
@@ -920,8 +917,8 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
920917
921918 component.push_back (secondType);
922919 } else {
923- if (!canSig->isCanonicalTypeInContext (secondType)) {
924- llvm::errs () << " Right hand side is not canonical : " ;
920+ if (!canSig->isReducedType (secondType)) {
921+ llvm::errs () << " Right hand side is not reduced : " ;
925922 reqt.dump (llvm::errs ());
926923 llvm::errs () << " \n " ;
927924 abort ();
@@ -1004,9 +1001,9 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
10041001 // Check same-type components for consistency.
10051002 for (const auto &pair : sameTypeComponents) {
10061003 if (pair.second .front ()->isTypeParameter () &&
1007- !canSig->isCanonicalTypeInContext (pair.second .front ())) {
1004+ !canSig->isReducedType (pair.second .front ())) {
10081005 llvm::errs () << " Abstract same-type requirement involving concrete types\n " ;
1009- llvm::errs () << " Canonical type: " << pair.first << " \n " ;
1006+ llvm::errs () << " Reduced type: " << pair.first << " \n " ;
10101007 llvm::errs () << " Left hand side of first requirement: "
10111008 << pair.second .front () << " \n " ;
10121009 abort ();
0 commit comments