@@ -178,8 +178,7 @@ static bool alwaysNoncopyable(Type ty) {
178
178
}
179
179
180
180
// / Preprocesses a type before querying whether it conforms to an invertible.
181
- static CanType preprocessTypeForInvertibleQuery (GenericEnvironment *env,
182
- Type orig) {
181
+ static CanType preprocessTypeForInvertibleQuery (Type orig) {
183
182
Type type = orig;
184
183
185
184
// Strip off any StorageType wrapper.
@@ -189,31 +188,34 @@ static CanType preprocessTypeForInvertibleQuery(GenericEnvironment *env,
189
188
if (auto wrapper = type->getAs <SILMoveOnlyWrappedType>())
190
189
type = wrapper->getInnerType ();
191
190
192
- // Turn any type parameters into archetypes.
193
- if (env)
194
- if (!type->hasArchetype () || type->hasOpenedExistential ())
195
- type = GenericEnvironment::mapTypeIntoContext (env, type);
191
+ // Pack expansions such as `repeat T` themselves do not have conformances,
192
+ // so check its pattern type for conformance.
193
+ if (auto *pet = type->getAs <PackExpansionType>()) {
194
+ type = pet->getPatternType ()->getCanonicalType ();
195
+ }
196
196
197
197
// Strip @lvalue and canonicalize.
198
198
auto canType = type->getRValueType ()->getCanonicalType ();
199
199
return canType;
200
200
}
201
201
202
202
// / \returns true iff this type lacks conformance to Copyable.
203
- bool TypeBase::isNoncopyable (GenericEnvironment *env ) {
204
- auto canType = preprocessTypeForInvertibleQuery (env, this );
203
+ bool TypeBase::isNoncopyable () {
204
+ auto canType = preprocessTypeForInvertibleQuery (this );
205
205
auto &ctx = canType->getASTContext ();
206
206
207
207
// for legacy-mode queries that are not dependent on conformances to Copyable
208
208
if (!ctx.LangOpts .hasFeature (Feature::NoncopyableGenerics))
209
209
return alwaysNoncopyable (canType);
210
210
211
+ assert (!hasTypeParameter ()
212
+ && " requires a contextual type; use mapTypeIntoContext" );
211
213
IsNoncopyableRequest request{canType};
212
214
return evaluateOrDefault (ctx.evaluator , request, /* default=*/ true );
213
215
}
214
216
215
- bool TypeBase::isEscapable (GenericEnvironment *env ) {
216
- auto canType = preprocessTypeForInvertibleQuery (env, this );
217
+ bool TypeBase::isEscapable () {
218
+ auto canType = preprocessTypeForInvertibleQuery (this );
217
219
auto &ctx = canType->getASTContext ();
218
220
219
221
// for legacy-mode queries that are not dependent on conformances to Escapable
@@ -224,6 +226,8 @@ bool TypeBase::isEscapable(GenericEnvironment *env) {
224
226
return true ;
225
227
}
226
228
229
+ assert (!hasTypeParameter ()
230
+ && " requires a contextual type; use mapTypeIntoContext" );
227
231
IsEscapableRequest request{canType};
228
232
return evaluateOrDefault (ctx.evaluator , request, /* default=*/ false );
229
233
}
0 commit comments