mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ASTDemangler: Use associated type declarations instead of identifiers as keys
This commit is contained in:
@@ -767,8 +767,8 @@ Type ASTBuilder::createExistentialMetatypeType(
|
||||
Type ASTBuilder::createConstrainedExistentialType(
|
||||
Type base, ArrayRef<BuiltRequirement> constraints,
|
||||
ArrayRef<BuiltInverseRequirement> inverseRequirements) {
|
||||
llvm::SmallDenseMap<Identifier, Type> primaryAssociatedTypes;
|
||||
llvm::SmallDenseSet<Identifier> claimed;
|
||||
llvm::SmallDenseMap<AssociatedTypeDecl *, Type> primaryAssociatedTypes;
|
||||
llvm::SmallDenseSet<AssociatedTypeDecl *> claimed;
|
||||
|
||||
for (const auto &req : constraints) {
|
||||
switch (req.getKind()) {
|
||||
@@ -782,7 +782,7 @@ Type ASTBuilder::createConstrainedExistentialType(
|
||||
if (auto *memberTy = req.getFirstType()->getAs<DependentMemberType>()) {
|
||||
if (memberTy->getBase()->is<GenericTypeParamType>()) {
|
||||
// This is the only case we understand so far.
|
||||
primaryAssociatedTypes[memberTy->getName()] = req.getSecondType();
|
||||
primaryAssociatedTypes[memberTy->getAssocType()] = req.getSecondType();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -799,7 +799,7 @@ Type ASTBuilder::createConstrainedExistentialType(
|
||||
|
||||
llvm::SmallVector<Type, 4> args;
|
||||
for (auto *assocTy : proto->getPrimaryAssociatedTypes()) {
|
||||
auto found = primaryAssociatedTypes.find(assocTy->getName());
|
||||
auto found = primaryAssociatedTypes.find(assocTy);
|
||||
if (found == primaryAssociatedTypes.end())
|
||||
return protoTy;
|
||||
args.push_back(found->second);
|
||||
|
||||
@@ -8,6 +8,10 @@ public protocol P<A, B> {
|
||||
associatedtype B
|
||||
}
|
||||
|
||||
public protocol P1<A> {
|
||||
associatedtype A
|
||||
}
|
||||
|
||||
public protocol Q<C> {
|
||||
associatedtype C
|
||||
}
|
||||
@@ -34,16 +38,29 @@ public func foo(_ a: (any P<Int, Float> & Q<String> & R).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & Q<String> & R & C<Bool>).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & Q<String> & R & AnyObject).Type) {}
|
||||
|
||||
public func foo(_ a: (any P & R).Type) {}
|
||||
public func foo(_ a: (any P & Q<String>).Type) {}
|
||||
public func foo(_ a: (any P & Q<String> & R).Type) {}
|
||||
public func foo(_ a: (any P & Q<String> & R & C<Bool>).Type) {}
|
||||
public func foo(_ a: (any P & Q<String> & R & AnyObject).Type) {}
|
||||
public func foo(_ a: (any P & P1).Type) {}
|
||||
public func foo(_ a: (any P & P1<String>).Type) {}
|
||||
public func foo(_ a: (any P & P1<String> & R).Type) {}
|
||||
public func foo(_ a: (any P & P1<String> & R & C<Bool>).Type) {}
|
||||
public func foo(_ a: (any P & P1<String> & R & AnyObject).Type) {}
|
||||
|
||||
public func foo(_ a: (any P<Int, Float> & Q).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & Q & R).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & Q & R & C<Bool>).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & Q & R & AnyObject).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & P1).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & P1 & R).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & P1 & R & C<Bool>).Type) {}
|
||||
public func foo(_ a: (any P<Int, Float> & P1 & R & AnyObject).Type) {}
|
||||
|
||||
public protocol Q2<C>: Q {}
|
||||
|
||||
public protocol Q3<C>: Q {
|
||||
associatedtype C
|
||||
}
|
||||
|
||||
public func foo(_ a: (any Q2<Int> & R).Type) {}
|
||||
public func foo(_ a: (any Q3<Int> & R).Type) {}
|
||||
public func foo(_ a: (any Q2 & Q3).Type) {}
|
||||
public func foo(_ a: (any Q2 & Q3<Int>).Type) {}
|
||||
public func foo2(_ a: (any Q2<Int> & Q3).Type) {}
|
||||
public func foo3(_ a: (any Q2<Int> & Q3<Int>).Type) {}
|
||||
|
||||
public struct Foo<each T, U> {
|
||||
public var a1: (repeat any P<each T, U> & R)
|
||||
|
||||
Reference in New Issue
Block a user