@@ -2532,7 +2532,6 @@ bool swift::diagnoseMissingOwnership(ParamSpecifier ownership,
2532
2532
auto options = resolution.getOptions ();
2533
2533
2534
2534
assert (!ty->hasError ());
2535
- assert (!options.contains (TypeResolutionFlags::SILType));
2536
2535
2537
2536
if (options.hasBase (TypeResolverContext::EnumElementDecl))
2538
2537
return false ; // no need for ownership in enum cases.
@@ -2879,8 +2878,8 @@ TypeResolver::resolveOpenedExistentialArchetype(
2879
2878
// The constraint type is written with respect to the surrounding
2880
2879
// generic environment.
2881
2880
constraintType = GenericEnvironment::mapTypeIntoContext (
2882
- resolution.getGenericSignature ().getGenericEnvironment (),
2883
- constraintType);
2881
+ resolution.getGenericSignature ().getGenericEnvironment (),
2882
+ constraintType);
2884
2883
2885
2884
// The opened existential type is formed by mapping the interface type
2886
2885
// into a new opened generic environment.
@@ -3781,8 +3780,7 @@ TypeResolver::resolveASTFunctionTypeParams(TupleTypeRepr *inputRepr,
3781
3780
3782
3781
// Validate the presence of ownership for a noncopyable parameter.
3783
3782
if (inStage (TypeResolutionStage::Interface)
3784
- && !ty->hasUnboundGenericType ()
3785
- && !options.contains (TypeResolutionFlags::SILMode)) {
3783
+ && !ty->hasUnboundGenericType ()) {
3786
3784
diagnoseMissingOwnership (ownership, eltTypeRepr, ty, resolution);
3787
3785
3788
3786
// @_staticExclusiveOnly types cannot be passed as 'inout' in function
@@ -5243,14 +5241,14 @@ NeverNullType TypeResolver::resolveVarargType(VarargTypeRepr *repr,
5243
5241
}
5244
5242
5245
5243
// do not allow move-only types as the element of a vararg
5246
- if (!element-> hasError ()
5247
- && inStage (TypeResolutionStage::Interface)
5248
- && !options. contains (TypeResolutionFlags::SILMode)
5249
- && isInterfaceTypeNoncopyable (
5250
- element, getDeclContext ()-> getGenericEnvironmentOfContext ())) {
5251
- diagnoseInvalid (repr, repr-> getLoc (), diag::noncopyable_generics_variadic,
5252
- element );
5253
- return ErrorType::get ( getASTContext ());
5244
+ if (inStage (TypeResolutionStage::Interface)) {
5245
+ auto contextTy = GenericEnvironment::mapTypeIntoContext (
5246
+ resolution. getGenericSignature (). getGenericEnvironment (), element);
5247
+ if (!contextTy-> hasError () && contextTy-> isNoncopyable ()) {
5248
+ diagnoseInvalid (repr, repr-> getLoc (), diag::noncopyable_generics_variadic,
5249
+ element);
5250
+ return ErrorType::get ( getASTContext () );
5251
+ }
5254
5252
}
5255
5253
5256
5254
return element;
@@ -5401,7 +5399,6 @@ NeverNullType TypeResolver::resolvePackElement(PackElementTypeRepr *repr,
5401
5399
NeverNullType TypeResolver::resolveTupleType (TupleTypeRepr *repr,
5402
5400
TypeResolutionOptions options) {
5403
5401
auto &ctx = getASTContext ();
5404
- auto *dc = getDeclContext ();
5405
5402
5406
5403
SmallVector<TupleTypeElt, 8 > elements;
5407
5404
elements.reserve (repr->getNumElements ());
@@ -5429,13 +5426,16 @@ NeverNullType TypeResolver::resolveTupleType(TupleTypeRepr *repr,
5429
5426
// Track the presence of a noncopyable field for diagnostic purposes only.
5430
5427
// We don't need to re-diagnose if a tuple contains another tuple, though,
5431
5428
// since we should've diagnosed the inner tuple already.
5432
- if (inStage (TypeResolutionStage::Interface)
5433
- && !options.contains (TypeResolutionFlags::SILMode)
5434
- && !ty->hasUnboundGenericType ()
5435
- && isInterfaceTypeNoncopyable (ty, dc->getGenericEnvironmentOfContext ())
5436
- && !ctx.LangOpts .hasFeature (Feature::MoveOnlyTuples)
5437
- && !moveOnlyElementIndex.has_value () && !isa<TupleTypeRepr>(tyR)) {
5438
- moveOnlyElementIndex = i;
5429
+ if (!ctx.LangOpts .hasFeature (Feature::MoveOnlyTuples) &&
5430
+ !options.contains (TypeResolutionFlags::SILMode) &&
5431
+ inStage (TypeResolutionStage::Interface) &&
5432
+ !moveOnlyElementIndex.has_value () &&
5433
+ !ty->hasUnboundGenericType () &&
5434
+ !isa<TupleTypeRepr>(tyR)) {
5435
+ auto contextTy = GenericEnvironment::mapTypeIntoContext (
5436
+ resolution.getGenericSignature ().getGenericEnvironment (), ty);
5437
+ if (contextTy->isNoncopyable ())
5438
+ moveOnlyElementIndex = i;
5439
5439
}
5440
5440
5441
5441
auto eltName = repr->getElementName (i);
0 commit comments