@@ -2043,39 +2043,26 @@ bool TypeChecker::getDefaultGenericArgumentsString(
2043
2043
return ;
2044
2044
}
2045
2045
2046
- auto contextTy = typeDecl->mapTypeIntoContext (genericParamTy);
2047
- if (auto archetypeTy = contextTy->getAs <ArchetypeType>()) {
2048
- SmallVector<Type, 2 > members;
2046
+ auto genericSig = typeDecl->getGenericSignature ();
2049
2047
2050
- bool hasExplicitAnyObject = archetypeTy->requiresClass ();
2051
- if (auto superclass = archetypeTy->getSuperclass ()) {
2052
- hasExplicitAnyObject = false ;
2053
- members.push_back (superclass);
2054
- }
2055
-
2056
- for (auto proto : archetypeTy->getConformsTo ()) {
2057
- members.push_back (proto->getDeclaredInterfaceType ());
2058
- if (proto->requiresClass ())
2059
- hasExplicitAnyObject = false ;
2060
- }
2061
-
2062
- if (hasExplicitAnyObject)
2063
- members.push_back (typeDecl->getASTContext ().getAnyObjectConstraint ());
2064
-
2065
- auto type = ProtocolCompositionType::get (typeDecl->getASTContext (),
2066
- members, hasExplicitAnyObject);
2048
+ auto concreteTy = genericSig->getConcreteType (genericParamTy);
2049
+ if (concreteTy) {
2050
+ genericParamText << concreteTy;
2051
+ return ;
2052
+ }
2067
2053
2068
- if (type-> isObjCExistentialType () || type-> isAny ()) {
2069
- genericParamText << type;
2070
- return ;
2071
- }
2054
+ auto upperBound = genericSig-> getUpperBound (
2055
+ genericParamTy,
2056
+ /* forExistentialSelf= */ false ,
2057
+ /* withParameterizedProtocols= */ false );
2072
2058
2073
- genericParamText << " <# " << genericParam-> getName () << " : " ;
2074
- genericParamText << type << " #> " ;
2059
+ if (upperBound-> isObjCExistentialType () || upperBound-> isAny ()) {
2060
+ genericParamText << upperBound ;
2075
2061
return ;
2076
2062
}
2077
2063
2078
- genericParamText << contextTy;
2064
+ genericParamText << " <#" << genericParam->getName () << " : " ;
2065
+ genericParamText << upperBound << " #>" ;
2079
2066
};
2080
2067
2081
2068
llvm::interleave (typeDecl->getInnermostGenericParamTypes (),
0 commit comments