mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintSystem] Add a locator element to represent a generic type
This locator is going to be used as a "parent" element for "generic argument" elements.
This commit is contained in:
committed by
Pavel Yaskevich
parent
1dd6d349d1
commit
17b09a801e
@@ -643,6 +643,20 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LocatorPathElt::GenericType : public StoredPointerElement<TypeBase> {
|
||||||
|
public:
|
||||||
|
GenericType(Type type)
|
||||||
|
: StoredPointerElement(PathElementKind::GenericType, type.getPointer()) {
|
||||||
|
assert(type->getDesugaredType()->is<BoundGenericType>());
|
||||||
|
}
|
||||||
|
|
||||||
|
Type getType() const { return getStoredPointer(); }
|
||||||
|
|
||||||
|
static bool classof(const LocatorPathElt *elt) {
|
||||||
|
return elt->getKind() == PathElementKind::GenericType;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// Abstract superclass for any kind of tuple element.
|
/// Abstract superclass for any kind of tuple element.
|
||||||
class LocatorPathElt::AnyTupleElement : public StoredIntegerElement<1> {
|
class LocatorPathElt::AnyTupleElement : public StoredIntegerElement<1> {
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ CUSTOM_LOCATOR_PATH_ELT(SynthesizedArgument)
|
|||||||
/// path components.
|
/// path components.
|
||||||
CUSTOM_LOCATOR_PATH_ELT(TupleType)
|
CUSTOM_LOCATOR_PATH_ELT(TupleType)
|
||||||
|
|
||||||
|
/// A generic type, which provides context for subsequent generic
|
||||||
|
/// argument path components.
|
||||||
|
CUSTOM_LOCATOR_PATH_ELT(GenericType)
|
||||||
|
|
||||||
/// Tuple elements.
|
/// Tuple elements.
|
||||||
ABSTRACT_LOCATOR_PATH_ELT(AnyTupleElement)
|
ABSTRACT_LOCATOR_PATH_ELT(AnyTupleElement)
|
||||||
/// A tuple element referenced by position.
|
/// A tuple element referenced by position.
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
|
|||||||
case ConstraintLocator::GenericParameter:
|
case ConstraintLocator::GenericParameter:
|
||||||
case ConstraintLocator::GenericArgument:
|
case ConstraintLocator::GenericArgument:
|
||||||
case ConstraintLocator::TupleType:
|
case ConstraintLocator::TupleType:
|
||||||
|
case ConstraintLocator::GenericType:
|
||||||
case ConstraintLocator::NamedTupleElement:
|
case ConstraintLocator::NamedTupleElement:
|
||||||
case ConstraintLocator::TupleElement:
|
case ConstraintLocator::TupleElement:
|
||||||
case ConstraintLocator::ProtocolRequirement:
|
case ConstraintLocator::ProtocolRequirement:
|
||||||
@@ -242,6 +243,12 @@ void LocatorPathElt::dump(raw_ostream &out) const {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ConstraintLocator::GenericType: {
|
||||||
|
auto genericTyElt = elt.castTo<LocatorPathElt::GenericType>();
|
||||||
|
out << "generic type '" << genericTyElt.getType()->getString(PO) << "'";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ConstraintLocator::NamedTupleElement: {
|
case ConstraintLocator::NamedTupleElement: {
|
||||||
auto tupleElt = elt.castTo<LocatorPathElt::NamedTupleElement>();
|
auto tupleElt = elt.castTo<LocatorPathElt::NamedTupleElement>();
|
||||||
out << "named tuple element #" << llvm::utostr(tupleElt.getIndex());
|
out << "named tuple element #" << llvm::utostr(tupleElt.getIndex());
|
||||||
|
|||||||
@@ -5372,6 +5372,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ConstraintLocator::TupleType:
|
case ConstraintLocator::TupleType:
|
||||||
|
case ConstraintLocator::GenericType:
|
||||||
path = path.slice(1);
|
path = path.slice(1);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user