|
22 | 22 | #include "swift/AST/Decl.h" |
23 | 23 | #include "swift/AST/DiagnosticEngine.h" |
24 | 24 | #include "swift/AST/Expr.h" |
25 | | -#include "swift/AST/GenericEnvironment.h" |
26 | 25 | #include "swift/AST/Identifier.h" |
27 | 26 | #include "swift/AST/OperatorNameLookup.h" |
28 | 27 | #include "swift/AST/Types.h" |
@@ -99,53 +98,7 @@ class FailureDiagnostic { |
99 | 98 |
|
100 | 99 | /// Resolve type variables present in the raw type, if any. |
101 | 100 | Type resolveType(Type rawType, bool reconstituteSugar = false, |
102 | | - bool wantRValue = true) const { |
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, expansion->getCountType()); |
121 | | - } |
122 | | - |
123 | | - Type GP = typeVar->getImpl().getGenericParameter(); |
124 | | - return resolvedType->is<UnresolvedType>() && GP ? GP : resolvedType; |
125 | | - } |
126 | | - |
127 | | - if (type->hasElementArchetype()) { |
128 | | - auto *env = getDC()->getGenericEnvironmentOfContext(); |
129 | | - return env->mapElementTypeIntoPackContext(type); |
130 | | - } |
131 | | - |
132 | | - if (auto *packType = type->getAs<PackType>()) { |
133 | | - if (packType->getNumElements() == 1) { |
134 | | - auto eltType = resolveType(packType->getElementType(0)); |
135 | | - if (auto expansion = eltType->getAs<PackExpansionType>()) |
136 | | - return expansion->getPatternType(); |
137 | | - } |
138 | | - } |
139 | | - |
140 | | - return type->isPlaceholder() |
141 | | - ? Type(type->getASTContext().TheUnresolvedType) |
142 | | - : type; |
143 | | - }); |
144 | | - |
145 | | - if (reconstituteSugar) |
146 | | - rawType = rawType->reconstituteSugar(/*recursive*/ true); |
147 | | - return wantRValue ? rawType->getRValueType() : rawType; |
148 | | - } |
| 101 | + bool wantRValue = true) const; |
149 | 102 |
|
150 | 103 | template <typename... ArgTypes> |
151 | 104 | InFlightDiagnostic emitDiagnostic(ArgTypes &&... Args) const; |
|
0 commit comments