@@ -2532,7 +2532,6 @@ bool swift::diagnoseMissingOwnership(ParamSpecifier ownership,
25322532 auto options = resolution.getOptions ();
25332533
25342534 assert (!ty->hasError ());
2535- assert (!options.contains (TypeResolutionFlags::SILType));
25362535
25372536 if (options.hasBase (TypeResolverContext::EnumElementDecl))
25382537 return false ; // no need for ownership in enum cases.
@@ -2879,8 +2878,8 @@ TypeResolver::resolveOpenedExistentialArchetype(
28792878 // The constraint type is written with respect to the surrounding
28802879 // generic environment.
28812880 constraintType = GenericEnvironment::mapTypeIntoContext (
2882- resolution.getGenericSignature ().getGenericEnvironment (),
2883- constraintType);
2881+ resolution.getGenericSignature ().getGenericEnvironment (),
2882+ constraintType);
28842883
28852884 // The opened existential type is formed by mapping the interface type
28862885 // into a new opened generic environment.
@@ -3781,8 +3780,7 @@ TypeResolver::resolveASTFunctionTypeParams(TupleTypeRepr *inputRepr,
37813780
37823781 // Validate the presence of ownership for a noncopyable parameter.
37833782 if (inStage (TypeResolutionStage::Interface)
3784- && !ty->hasUnboundGenericType ()
3785- && !options.contains (TypeResolutionFlags::SILMode)) {
3783+ && !ty->hasUnboundGenericType ()) {
37863784 diagnoseMissingOwnership (ownership, eltTypeRepr, ty, resolution);
37873785
37883786 // @_staticExclusiveOnly types cannot be passed as 'inout' in function
@@ -5243,14 +5241,14 @@ NeverNullType TypeResolver::resolveVarargType(VarargTypeRepr *repr,
52435241 }
52445242
52455243 // 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+ }
52545252 }
52555253
52565254 return element;
@@ -5401,7 +5399,6 @@ NeverNullType TypeResolver::resolvePackElement(PackElementTypeRepr *repr,
54015399NeverNullType TypeResolver::resolveTupleType (TupleTypeRepr *repr,
54025400 TypeResolutionOptions options) {
54035401 auto &ctx = getASTContext ();
5404- auto *dc = getDeclContext ();
54055402
54065403 SmallVector<TupleTypeElt, 8 > elements;
54075404 elements.reserve (repr->getNumElements ());
@@ -5429,13 +5426,16 @@ NeverNullType TypeResolver::resolveTupleType(TupleTypeRepr *repr,
54295426 // Track the presence of a noncopyable field for diagnostic purposes only.
54305427 // We don't need to re-diagnose if a tuple contains another tuple, though,
54315428 // 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;
54395439 }
54405440
54415441 auto eltName = repr->getElementName (i);
0 commit comments