@@ -99,37 +99,42 @@ class FailureDiagnostic {
99
99
// / Resolve type variables present in the raw type, if any.
100
100
Type resolveType (Type rawType, bool reconstituteSugar = false ,
101
101
bool wantRValue = true ) const {
102
- if (rawType->hasTypeVariable () || rawType->hasPlaceholder ()) {
103
- rawType = rawType.transform ([&](Type type) -> Type {
104
- if (auto *typeVar = type->getAs <TypeVariableType>()) {
105
- auto resolvedType = S.simplifyType (typeVar);
106
-
107
- if (!resolvedType->hasUnresolvedType ())
108
- return resolvedType;
109
-
110
- // If type variable was simplified to an unresolved pack expansion
111
- // type, let's examine its original pattern type because it could
112
- // contain type variables replaceable with their generic parameter
113
- // types.
114
- if (auto *expansion = resolvedType->getAs <PackExpansionType>()) {
115
- auto *locator = typeVar->getImpl ().getLocator ();
116
- auto *openedExpansionTy =
117
- locator->castLastElementTo <LocatorPathElt::PackExpansionType>()
118
- .getOpenedType ();
119
- auto patternType = resolveType (openedExpansionTy->getPatternType ());
120
- return PackExpansionType::get (patternType,
121
- expansion->getCountType ());
122
- }
123
-
124
- Type GP = typeVar->getImpl ().getGenericParameter ();
125
- return resolvedType->is <UnresolvedType>() && GP ? GP : resolvedType;
102
+ rawType = rawType.transform ([&](Type type) -> Type {
103
+ if (auto *typeVar = type->getAs <TypeVariableType>()) {
104
+ auto resolvedType = S.simplifyType (typeVar);
105
+
106
+ if (!resolvedType->hasUnresolvedType ())
107
+ return resolvedType;
108
+
109
+ // If type variable was simplified to an unresolved pack expansion
110
+ // type, let's examine its original pattern type because it could
111
+ // contain type variables replaceable with their generic parameter
112
+ // types.
113
+ if (auto *expansion = resolvedType->getAs <PackExpansionType>()) {
114
+ auto *locator = typeVar->getImpl ().getLocator ();
115
+ auto *openedExpansionTy =
116
+ locator->castLastElementTo <LocatorPathElt::PackExpansionType>()
117
+ .getOpenedType ();
118
+ auto patternType = resolveType (openedExpansionTy->getPatternType ());
119
+ return PackExpansionType::get (patternType, expansion->getCountType ());
126
120
}
127
121
128
- return type->isPlaceholder ()
129
- ? Type (type->getASTContext ().TheUnresolvedType )
130
- : type;
131
- });
132
- }
122
+ Type GP = typeVar->getImpl ().getGenericParameter ();
123
+ return resolvedType->is <UnresolvedType>() && GP ? GP : resolvedType;
124
+ }
125
+
126
+ if (auto *packType = type->getAs <PackType>()) {
127
+ if (packType->getNumElements () == 1 ) {
128
+ auto eltType = resolveType (packType->getElementType (0 ));
129
+ if (auto expansion = eltType->getAs <PackExpansionType>())
130
+ return expansion->getPatternType ();
131
+ }
132
+ }
133
+
134
+ return type->isPlaceholder ()
135
+ ? Type (type->getASTContext ().TheUnresolvedType )
136
+ : type;
137
+ });
133
138
134
139
if (reconstituteSugar)
135
140
rawType = rawType->reconstituteSugar (/* recursive*/ true );
0 commit comments