diff --git a/include/swift/AST/DeclContext.h b/include/swift/AST/DeclContext.h index 571cecdd3c3..b524ac23402 100644 --- a/include/swift/AST/DeclContext.h +++ b/include/swift/AST/DeclContext.h @@ -367,10 +367,6 @@ public: /// Determine whether the innermost context is generic. bool isInnermostContextGeneric() const; - - /// Determine whether the innermost context is either a generic type context, - /// or a concrete type nested inside a generic type context. - bool isGenericTypeContext() const; /// Determine the maximum depth of the current generic type context's generic /// parameters. If the current context is not a generic type context, returns diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index a895d4e4922..2949d08bb57 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -4472,7 +4472,7 @@ bool EnumElementDecl::computeType() { if (getArgumentType()) resultTy = FunctionType::get(getArgumentType(), resultTy); - if (ED->isGenericTypeContext()) + if (ED->isGenericContext()) resultTy = PolymorphicFunctionType::get(argTy, resultTy, ED->getGenericParamsOfContext()); else diff --git a/lib/AST/DeclContext.cpp b/lib/AST/DeclContext.cpp index 1bd200b6bb7..eec599757db 100644 --- a/lib/AST/DeclContext.cpp +++ b/lib/AST/DeclContext.cpp @@ -431,17 +431,6 @@ bool DeclContext::isGenericContext() const { llvm_unreachable("illegal declcontext hierarchy"); } -/// Determine whether the given context nested inside a generic type context -/// with no local contexts in between. -bool DeclContext::isGenericTypeContext() const { - for (const auto *dc = this; dc->isTypeContext(); dc = dc->getParent()) { - if (dc->isInnermostContextGeneric()) - return true; - } - - return false; -} - /// Determine the maximum depth of the current generic type context's generic /// parameters. If the current context is not a generic type context, returns /// the maximum depth of any generic parameter in this context. diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index 3299c075d44..3f7cc1a269a 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -726,6 +726,13 @@ TypeBase::gatherAllSubstitutions(Module *module, llvm_unreachable("Not a nominal or bound generic type"); } + // Add forwarding substitutions from the outer context if we have + // a type nested inside a generic function. + if (auto *outerGenericParams = parentDC->getGenericParamsOfContext()) { + for (auto archetype : outerGenericParams->getAllNestedArchetypes()) + substitutions[archetype] = archetype; + } + // Collect all of the archetypes. SmallVector allArchetypesList; ArrayRef allArchetypes = genericParams->getAllArchetypes(); diff --git a/lib/SIL/TypeLowering.cpp b/lib/SIL/TypeLowering.cpp index e536034c447..4d80c0a2b55 100644 --- a/lib/SIL/TypeLowering.cpp +++ b/lib/SIL/TypeLowering.cpp @@ -1732,13 +1732,12 @@ static CanAnyFunctionType getIVarInitDestroyerInterfaceType(ClassDecl *cd, GenericParamList * TypeConverter::getEffectiveGenericParams(AnyFunctionRef fn, CaptureInfo captureInfo) { - auto dc = fn.getAsDeclContext()->getParent(); + auto dc = fn.getAsDeclContext(); - if (dc->isLocalContext() && - !captureInfo.hasGenericParamCaptures()) { + if (dc->getParent()->isLocalContext() && + !captureInfo.hasGenericParamCaptures()) return nullptr; - } - + return dc->getGenericParamsOfContext(); } @@ -1747,14 +1746,9 @@ TypeConverter::getEffectiveGenericSignature(AnyFunctionRef fn, CaptureInfo captureInfo) { auto dc = fn.getAsDeclContext(); - // If this is a non-generic local function that does not capture any - // generic type parameters from the outer context, don't need a - // signature at all. - if (!dc->isInnermostContextGeneric() && - dc->getParent()->isLocalContext() && - !captureInfo.hasGenericParamCaptures()) { + if (dc->getParent()->isLocalContext() && + !captureInfo.hasGenericParamCaptures()) return nullptr; - } if (auto sig = dc->getGenericSignatureOfContext()) return sig->getCanonicalSignature(); @@ -1832,8 +1826,7 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) { switch (c.kind) { case SILDeclRef::Kind::Func: { if (auto *ACE = c.loc.dyn_cast()) { - // TODO: Substitute out archetypes from the enclosing context with generic - // parameters. + // FIXME: Closures could have an interface type computed by Sema. auto funcTy = cast(ACE->getType()->getCanonicalType()); funcTy = cast( ArchetypeBuilder::mapTypeOutOfContext(ACE->getParent(), funcTy) @@ -1844,10 +1837,6 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) { FuncDecl *func = cast(vd); auto funcTy = cast( func->getInterfaceType()->getCanonicalType()); - if (func->getParent() && func->getParent()->isLocalContext()) - funcTy = cast( - ArchetypeBuilder::mapTypeOutOfContext(func->getParent(), funcTy) - ->getCanonicalType()); funcTy = cast(replaceDynamicSelfWithSelf(funcTy)); return getFunctionInterfaceTypeWithCaptures(funcTy, func); } @@ -1909,22 +1898,6 @@ TypeConverter::getConstantContextGenericParams(SILDeclRef c) { FuncDecl *func = cast(vd); auto captureInfo = getLoweredLocalCaptures(func); - // FIXME: This is really weird: - // 1) For generic functions, generic methods and generic - // local functions, we return the function's generic - // parameter list twice. - // 2) For non-generic methods inside generic types, we - // return the generic type's parameters and nullptr. - // 3) For non-generic local functions, we return the - // outer function's parameters and nullptr. - // - // Local generic functions could probably be modeled better - // at the SIL level. - if (func->isInnermostContextGeneric() || - func->getDeclContext()->isGenericTypeContext()) { - if (auto GP = func->getGenericParamsOfContext()) - return {GP, func->getGenericParams()}; - } return {getEffectiveGenericParams(func, captureInfo), func->getGenericParams()}; } diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index 0b926a9bdd3..c5666e51b8d 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -1169,9 +1169,8 @@ public: } ArrayRef subs; - if (e->getDeclRef().isSpecialized()) { + if (e->getDeclRef().isSpecialized()) subs = e->getDeclRef().getSubstitutions(); - } // Enum case constructor references are open-coded. if (isa(e->getDecl())) @@ -1191,14 +1190,13 @@ public: captures); ApplyCallee->setCaptures(std::move(captures)); } - - if (subs.empty() && afd->getCaptureInfo().hasGenericParamCaptures()) { - subs = SGF.getForwardingSubstitutions(); - } } // If there are substitutions, add them, always at depth 0. - if (!subs.empty()) + if (!subs.empty() && + (!afd || + !afd->getDeclContext()->isLocalContext() || + afd->getCaptureInfo().hasGenericParamCaptures())) ApplyCallee->setSubstitutions(SGF, e, subs, 0); } diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp index 1c8e79d0581..b1a636eb6ea 100644 --- a/lib/SILGen/SILGenFunction.cpp +++ b/lib/SILGen/SILGenFunction.cpp @@ -337,6 +337,7 @@ SILGenFunction::emitClosureValue(SILLocation loc, SILDeclRef constant, ArrayRef subs) { auto closure = *constant.getAnyFunctionRef(); auto captureInfo = closure.getCaptureInfo(); + auto loweredCaptureInfo = SGM.Types.getLoweredLocalCaptures(closure); assert(((constant.uncurryLevel == 1 && captureInfo.hasLocalCaptures()) || @@ -351,17 +352,21 @@ SILGenFunction::emitClosureValue(SILLocation loc, SILDeclRef constant, // Apply substitutions. auto pft = constantInfo.SILFnType; + auto *dc = closure.getAsDeclContext()->getParent(); + if (dc->isLocalContext() && !loweredCaptureInfo.hasGenericParamCaptures()) { + // If the lowered function type is not polymorphic but we were given + // substitutions, we have a closure in a generic context which does not + // capture generic parameters. Just drop the substitutions. + subs = { }; + } else if (closure.getAbstractClosureExpr()) { + // If we have a closure expression in generic context, Sema won't give + // us substitutions, so we just use the forwarding substitutions from + // context. + subs = getForwardingSubstitutions(); + } + bool wasSpecialized = false; - if (pft->isPolymorphic()) { - // If the lowered function type is generic but Sema did not hand us any - // substitutions, the function is a local function that appears in a - // generic context but does not have a generic parameter list of its own; - // just use our forwarding substitutions. - if (subs.empty()) { - assert(closure.getAsDeclContext()->isLocalContext() && - "cannot reference generic global function without substitutions"); - subs = getForwardingSubstitutions(); - } + if (!subs.empty()) { auto specialized = pft->substGenericArgs(F.getModule(), F.getModule().getSwiftModule(), subs); diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 81809ac3b75..5e16e5a0166 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -754,7 +754,8 @@ namespace { ConcreteDeclRef memberRef; Type refTy; Type dynamicSelfFnType; - if (openedFullType->hasTypeVariable()) { + if (member->getInterfaceType()->is() || + openedFullType->hasTypeVariable()) { // We require substitutions. Figure out what they are. // Figure out the declaration context where we'll get the generic diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index d752a99c03d..6a4e7449098 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -3462,7 +3462,7 @@ void swift::collectDefaultImplementationForProtocolMembers(ProtocolDecl *PD, VD->getFullName()); if (Result.OtherViables.empty()) continue; - if (!Result.Favored->getDeclContext()->isGenericTypeContext()) + if (!Result.Favored->getDeclContext()->isGenericContext()) continue; for (ValueDecl *Default : Result.OtherViables) { if (Default->getDeclContext()->isExtensionContext()) { diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index c9dc82078e1..6f107033979 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -1274,7 +1274,7 @@ void TypeChecker::completePropertyBehaviorStorage(VarDecl *VD, // Add the witnesses to the conformance. ArrayRef MemberSubs; - if (DC->isGenericTypeContext()) { + if (DC->isGenericContext()) { MemberSubs = DC->getGenericParamsOfContext() ->getForwardingSubstitutions(Context); } @@ -1448,7 +1448,7 @@ void TypeChecker::completePropertyBehaviorParameter(VarDecl *VD, // Add the witnesses to the conformance. ArrayRef MemberSubs; - if (DC->isGenericTypeContext()) { + if (DC->isGenericContext()) { MemberSubs = DC->getGenericParamsOfContext() ->getForwardingSubstitutions(Context); } @@ -2079,7 +2079,7 @@ swift::createDesignatedInitOverride(TypeChecker &tc, // // We might have to apply substitutions, if for example we have a declaration // like 'class A : B'. - if (superclassDecl->isGenericTypeContext()) { + if (superclassDecl->isGenericContext()) { if (auto *superclassSig = superclassDecl->getGenericSignatureOfContext()) { auto *moduleDecl = classDecl->getParentModule(); auto subs = superclassTy->gatherAllSubstitutions( @@ -2127,7 +2127,7 @@ swift::createDesignatedInitOverride(TypeChecker &tc, auto selfType = configureImplicitSelf(tc, ctor); // Set the interface type of the initializer. - if (classDecl->isGenericTypeContext()) { + if (classDecl->isGenericContext()) { ctor->setGenericSignature(classDecl->getGenericSignatureOfContext()); tc.configureInterfaceType(ctor); } diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index a1a3637b9e5..4c6af5c944b 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -1294,7 +1294,7 @@ void swift::configureConstructorType(ConstructorDecl *ctor, fnType = FunctionType::get(argType, resultType, extInfo); } Type selfMetaType = MetatypeType::get(selfType->getInOutObjectType()); - if (ctor->getDeclContext()->isGenericTypeContext()) { + if (ctor->getDeclContext()->isGenericContext()) { allocFnType = PolymorphicFunctionType::get(selfMetaType, fnType, outerGenericParams); initFnType = PolymorphicFunctionType::get(selfType, fnType, @@ -3996,7 +3996,7 @@ public: GenericParamList *outerGenericParams = nullptr; auto paramLists = FD->getParameterLists(); bool hasSelf = FD->getDeclContext()->isTypeContext(); - if (FD->getDeclContext()->isGenericTypeContext()) + if (FD->getDeclContext()->isGenericContext()) outerGenericParams = FD->getDeclContext()->getGenericParamsOfContext(); for (unsigned i = 0, e = paramLists.size(); i != e; ++i) { @@ -4359,7 +4359,7 @@ public: // Assign archetypes. finalizeGenericParamList(builder, gp, FD, TC); } - } else if (FD->getDeclContext()->isGenericTypeContext()) { + } else if (FD->getDeclContext()->isGenericContext()) { if (TC.validateGenericFuncSignature(FD)) { TC.markInvalidGenericSignature(FD); } else if (!FD->hasType()) { @@ -5815,7 +5815,7 @@ public: // case the enclosing enum type was illegally declared inside of a generic // context. (In that case, we'll post a diagnostic while visiting the // parent enum.) - if (EED->getDeclContext()->isGenericTypeContext()) + if (EED->getDeclContext()->isGenericContext()) computeEnumElementInterfaceType(EED); // Require the carried type to be materializable. @@ -5988,7 +5988,7 @@ public: // Assign archetypes. finalizeGenericParamList(builder, gp, CD, TC); } - } else if (CD->getDeclContext()->isGenericTypeContext()) { + } else if (CD->getDeclContext()->isGenericContext()) { if (TC.validateGenericFuncSignature(CD)) { TC.markInvalidGenericSignature(CD); } else { @@ -6132,7 +6132,7 @@ public: Type SelfTy = configureImplicitSelf(TC, DD); - if (DD->getDeclContext()->isGenericTypeContext()) + if (DD->getDeclContext()->isGenericContext()) TC.validateGenericFuncSignature(DD); if (semaFuncParamPatterns(DD)) { @@ -6142,7 +6142,7 @@ public: if (!DD->hasType()) { Type FnTy; - if (DD->getDeclContext()->isGenericTypeContext()) { + if (DD->getDeclContext()->isGenericContext()) { FnTy = PolymorphicFunctionType::get(SelfTy, TupleType::getEmpty(TC.Context), DD->getDeclContext()->getGenericParamsOfContext()); diff --git a/lib/Sema/TypeCheckExpr.cpp b/lib/Sema/TypeCheckExpr.cpp index 2c88175ba74..cab1e32b447 100644 --- a/lib/Sema/TypeCheckExpr.cpp +++ b/lib/Sema/TypeCheckExpr.cpp @@ -1277,20 +1277,15 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) { } } - // Since nested generic functions are not supported yet, the only case where - // generic parameters can be captured is by closures and non-generic local - // functions. - // - // So we only set GenericParamCaptures if we have a closure, or a - // non-generic function defined inside a local context. auto *AFD = AFR.getAbstractFunctionDecl(); - if (!AFD || - (!AFD->getGenericParams() && - AFD->getDeclContext()->isLocalContext())) { - AFR.getCaptureInfo() - .setGenericParamCaptures(GenericParamCaptureLoc.isValid()); + if (AFD) { + if (AFD->getGenericParams()) + AFR.getCaptureInfo().setGenericParamCaptures(true); } + if (GenericParamCaptureLoc.isValid()) + AFR.getCaptureInfo().setGenericParamCaptures(true); + if (Captures.empty()) AFR.getCaptureInfo().setCaptures(None); else diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp index 5d310e368ed..8e2a40a1b16 100644 --- a/lib/Sema/TypeCheckGeneric.cpp +++ b/lib/Sema/TypeCheckGeneric.cpp @@ -861,22 +861,24 @@ bool TypeChecker::checkGenericArguments(DeclContext *dc, SourceLoc loc, auto genericParams = genericSig->getGenericParams(); - unsigned genericTypeDepth = - owner->getAnyNominal()->getGenericTypeContextDepth(); unsigned count = 0; + // If the type is nested inside a generic function, skip + // substitutions from the outer context. + unsigned start = (genericParams.size() - genericArgs.size()); + for (auto gp : genericParams) { - // Skip parameters that were introduced by outer generic - // function signatures. - if (gp->getDecl()->getDepth() < genericTypeDepth) - continue; - auto gpTy = gp->getCanonicalType()->castTo(); - substitutions[gpTy] = genericArgs[count++]; + if (count >= start) { + auto gpTy = gp->getCanonicalType()->castTo(); + substitutions[gpTy] = genericArgs[count - start]; + } + + count++; } // The number of generic type arguments being bound must be equal to the // total number of generic parameters in the current generic type context. - assert(count == genericArgs.size()); + assert(count - start == genericArgs.size()); // Check each of the requirements. Module *module = dc->getParentModule(); diff --git a/test/SILGen/generic_closures.swift b/test/SILGen/generic_closures.swift index e51b80a786c..01de7341875 100644 --- a/test/SILGen/generic_closures.swift +++ b/test/SILGen/generic_closures.swift @@ -116,18 +116,18 @@ class NestedGeneric { } } - // - // Ensure that nested closures capture the generic parameters of their nested - // context. +// +// Ensure that nested closures capture the generic parameters of their nested +// context. - // CHECK: sil hidden @_TF16generic_closures25nested_closure_in_generic{{.*}} : $@convention(thin) (@in T) -> @out T - // CHECK: function_ref [[OUTER_CLOSURE:@_TFF16generic_closures25nested_closure_in_genericurFxxU_FT_Q_]] - // CHECK: sil shared [[OUTER_CLOSURE]] : $@convention(thin) (@inout_aliasable T) -> @out T - // CHECK: function_ref [[INNER_CLOSURE:@_TFFF16generic_closures25nested_closure_in_genericurFxxU_FT_Q_U_FT_Q_]] - // CHECK: sil shared [[INNER_CLOSURE]] : $@convention(thin) (@inout_aliasable T) -> @out T { - func nested_closure_in_generic(_ x:T) -> T { - return { { x }() }() - } +// CHECK: sil hidden @_TF16generic_closures25nested_closure_in_generic{{.*}} : $@convention(thin) (@in T) -> @out T +// CHECK: function_ref [[OUTER_CLOSURE:@_TFF16generic_closures25nested_closure_in_genericurFxxU_FT_Q_]] +// CHECK: sil shared [[OUTER_CLOSURE]] : $@convention(thin) (@inout_aliasable T) -> @out T +// CHECK: function_ref [[INNER_CLOSURE:@_TFFF16generic_closures25nested_closure_in_genericurFxxU_FT_Q_U_FT_Q_]] +// CHECK: sil shared [[INNER_CLOSURE]] : $@convention(thin) (@inout_aliasable T) -> @out T { +func nested_closure_in_generic(_ x:T) -> T { + return { { x }() }() +} // CHECK-LABEL: sil hidden @_TF16generic_closures16local_properties func local_properties(_ t: inout T) { @@ -276,3 +276,21 @@ func outer_concrete(i: Int) { // CHECK: [[RESULT:%.*]] = apply [[FN]]({{.*}}) : $@convention(thin) <τ_0_0> (@in τ_0_0, Int) -> Int _ = inner_generic(u: i) } + +// CHECK-LABEL: sil hidden @_TF16generic_closures32mixed_generic_nongeneric_nestingurFT1tx_T_ : $@convention(thin) (@in T) -> () +func mixed_generic_nongeneric_nesting(t: T) { + func outer() { + func middle(u: U) { + func inner() -> U { + return u + } + inner() + } + middle(u: 11) + } + outer() +} + +// CHECK-LABEL: sil shared @_TFF16generic_closures32mixed_generic_nongeneric_nestingurFT1tx_T_L_5outerurFT_T_ : $@convention(thin) () -> () +// CHECK-LABEL: sil shared @_TFFF16generic_closures32mixed_generic_nongeneric_nestingurFT1tx_T_L_5outerurFT_T_L_6middleu__rFT1uqd___T_ : $@convention(thin) (@in U) -> () +// CHECK-LABEL: sil shared @_TFFFF16generic_closures32mixed_generic_nongeneric_nestingurFT1tx_T_L_5outerurFT_T_L_6middleu__rFT1uqd___T_L_5inneru__rfT_qd__ : $@convention(thin) (@owned @box U) -> @out U diff --git a/test/SILGen/interface_type_mangling.swift b/test/SILGen/interface_type_mangling.swift index 8691bec3012..91d9fcd7dfe 100644 --- a/test/SILGen/interface_type_mangling.swift +++ b/test/SILGen/interface_type_mangling.swift @@ -197,14 +197,14 @@ struct GenericTypeContext: GenericWitnessTest { typealias Tee = T var a: T - // CHECK-LABEL: sil shared @_TFFV23interface_type_mangling18GenericTypeContext23closureInGenericContexturFqd__T_L_3fooFTQ_Qd___T_ + // CHECK-LABEL: sil shared @_TFFV23interface_type_mangling18GenericTypeContext23closureInGenericContexturFqd__T_L_3foou__rFTxqd___T_ func closureInGenericContext(_ b: U) { func foo(_ x: T, _ y: U) { } foo(a, b) } - // CHECK-LABEL: sil shared @_TFFV23interface_type_mangling18GenericTypeContextg31closureInGenericPropertyContextxL_3fooFT_Q_ + // CHECK-LABEL: sil shared @_TFFV23interface_type_mangling18GenericTypeContextg31closureInGenericPropertyContextxL_3foourFT_x var closureInGenericPropertyContext: T { func foo() -> T { } diff --git a/test/SILGen/local_recursion.swift b/test/SILGen/local_recursion.swift index 9567ab45152..46a436744e8 100644 --- a/test/SILGen/local_recursion.swift +++ b/test/SILGen/local_recursion.swift @@ -29,6 +29,9 @@ func local_recursion(_ x: Int, y: Int) { // CHECK: apply [[MUTUALLY_RECURSIVE_REF]]([[X]], [[Y]], [[X]]) mutually_recursive_1(x) + // CHECK: [[MUTUALLY_RECURSIVE_REF:%.*]] = function_ref [[MUTUALLY_RECURSIVE_1]] + _ = mutually_recursive_1 + func transitive_capture_1(_ a: Int) -> Int { return x + a } @@ -95,6 +98,7 @@ func generic_local_recursion(_ x: T, y: U) { } self_recursive(x) + _ = self_recursive func transitive_capture_1(_ a: T) -> U { return toggle(a, y) @@ -104,10 +108,19 @@ func generic_local_recursion(_ x: T, y: U) { } transitive_capture_2(y) + _ = transitive_capture_2 func no_captures() {} no_captures() + _ = no_captures + + func transitive_no_captures() { + no_captures() + } + + transitive_no_captures() + _ = transitive_no_captures } func local_properties(_ x: Int, y: Int) -> Int { diff --git a/test/SILOptimizer/specialize_partial_apply.swift b/test/SILOptimizer/specialize_partial_apply.swift index 10595d23761..eea5b322711 100644 --- a/test/SILOptimizer/specialize_partial_apply.swift +++ b/test/SILOptimizer/specialize_partial_apply.swift @@ -18,7 +18,7 @@ struct MyError : ErrorProtocol { // args/result, which is expected in the returned closure. // CHECK-LABEL: sil shared [noinline] @_TTSg5Si___TF4test16generic_get_funcurFTxSb_Fxx : $@convention(thin) (Int, Bool) -> @owned @callee_owned (@in Int) -> @out Int { -// CHECK: [[F:%[0-9]+]] = function_ref @_TTSr5Si___TFF4test16generic_get_funcurFTxSb_FxxL_7genericfQ_Q_ : $@convention(thin) (@in Int, Bool, @owned @box Int) -> @out Int +// CHECK: [[F:%[0-9]+]] = function_ref @_TTSr5Si___TFF4test16generic_get_funcurFTxSb_FxxL_7genericurfxx : $@convention(thin) (@in Int, Bool, @owned @box Int) -> @out Int // CHECK: [[PA:%[0-9]+]] = partial_apply [[F]](%1, %{{[0-9]+}}) : $@convention(thin) (@in Int, Bool, @owned @box Int) -> @out Int // CHECK: return [[PA]] : $@callee_owned (@in Int) -> @out Int @inline(never) @@ -89,7 +89,7 @@ func testit3(_ b: Bool) -> Int { // args/result, which is expected in the returned closure. // CHECK-LABEL: sil shared [noinline] @_TTSg5Si___TF4test25generic_get_func_throwingurFSbFzxx : $@convention(thin) (Bool) -> @owned @callee_owned (@in Int) -> (@out Int, @error ErrorProtocol) { -// CHECK: [[F:%[0-9]+]] = function_ref @_TTSr5Si___TFF4test25generic_get_func_throwingurFSbFzxxL_7genericfzQ_Q_ : $@convention(thin) (@in Int, Bool) -> (@out Int, @error ErrorProtocol) +// CHECK: [[F:%[0-9]+]] = function_ref @_TTSr5Si___TFF4test25generic_get_func_throwingurFSbFzxxL_7genericurfzxx : $@convention(thin) (@in Int, Bool) -> (@out Int, @error ErrorProtocol) // CHECK: [[PA:%[0-9]+]] = partial_apply [[F]](%0) : $@convention(thin) (@in Int, Bool) -> (@out Int, @error ErrorProtocol) // CHECK: return [[PA]] : $@callee_owned (@in Int) -> (@out Int, @error ErrorProtocol) @inline(never) @@ -168,18 +168,18 @@ func testit3_throwing(_ b: Bool) -> Int { } } -// CHECK-LABEL: sil shared [transparent] [thunk] @_TTSr5Si___TFF4test16generic_get_funcurFTxSb_FxxL_7genericfQ_Q_ : $@convention(thin) (@in Int, Bool, @owned @box Int) -> @out Int { +// CHECK-LABEL: sil shared [transparent] [thunk] @_TTSr5Si___TFF4test16generic_get_funcurFTxSb_FxxL_7genericurfxx : $@convention(thin) (@in Int, Bool, @owned @box Int) -> @out Int { // CHECK: bb0(%0 : $*Int, %1 : $*Int, %2 : $Bool, %3 : $@box Int): // CHECK: [[LD:%[0-9]+]] = load %1 : $*Int -// CHECK: [[F:%[0-9]+]] = function_ref @_TTSg5Si___TFF4test16generic_get_funcurFTxSb_FxxL_7genericfQ_Q_ : $@convention(thin) (Int, Bool, @owned @box Int) -> Int +// CHECK: [[F:%[0-9]+]] = function_ref @_TTSg5Si___TFF4test16generic_get_funcurFTxSb_FxxL_7genericurfxx : $@convention(thin) (Int, Bool, @owned @box Int) -> Int // CHECK: [[RET:%[0-9]+]] = apply [[F]]([[LD]], %2, %3) : $@convention(thin) (Int, Bool, @owned @box Int) -> Int // CHECK: store [[RET]] to %0 : $*Int // CHECK: return %{{[0-9]*}} : $() -// CHECK-LABEL: sil shared [transparent] [thunk] @_TTSr5Si___TFF4test25generic_get_func_throwingurFSbFzxxL_7genericfzQ_Q_ : $@convention(thin) (@in Int, Bool) -> (@out Int, @error ErrorProtocol) { +// CHECK-LABEL: sil shared [transparent] [thunk] @_TTSr5Si___TFF4test25generic_get_func_throwingurFSbFzxxL_7genericurfzxx : $@convention(thin) (@in Int, Bool) -> (@out Int, @error ErrorProtocol) { // CHECK: bb0(%0 : $*Int, %1 : $*Int, %2 : $Bool): // CHECK: [[LD:%[0-9]+]] = load %1 : $*Int -// CHECK: [[F:%[0-9]+]] = function_ref @_TTSg5Si___TFF4test25generic_get_func_throwingurFSbFzxxL_7genericfzQ_Q_ : $@convention(thin) (Int, Bool) -> (Int, @error ErrorProtocol) +// CHECK: [[F:%[0-9]+]] = function_ref @_TTSg5Si___TFF4test25generic_get_func_throwingurFSbFzxxL_7genericurfzxx : $@convention(thin) (Int, Bool) -> (Int, @error ErrorProtocol) // CHECK: try_apply [[F]]([[LD]], %2) : $@convention(thin) (Int, Bool) -> (Int, @error ErrorProtocol), normal bb1, error bb2 // CHECK: bb1([[NORMAL:%[0-9]+]] : $Int): // CHECK: store [[NORMAL]] to %0 : $*Int diff --git a/validation-test/IDE/crashers/022-swift-typechecker-applygenericarguments.swift b/validation-test/IDE/crashers/022-swift-typechecker-applygenericarguments.swift deleted file mode 100644 index 5b76ebb4faf..00000000000 --- a/validation-test/IDE/crashers/022-swift-typechecker-applygenericarguments.swift +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s -// REQUIRES: asserts -protocol a{ -func g:P -protocol P{ -class B \ No newline at end of file diff --git a/validation-test/IDE/crashers/038-swift-mangle-mangler-getdecltypeformangling.swift b/validation-test/IDE/crashers/038-swift-mangle-mangler-getdecltypeformangling.swift deleted file mode 100644 index 8047b1d6bb1..00000000000 --- a/validation-test/IDE/crashers/038-swift-mangle-mangler-getdecltypeformangling.swift +++ /dev/null @@ -1,2 +0,0 @@ -// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s -struct astruct B diff --git a/validation-test/IDE/crashers_fixed/038-swift-mangle-mangler-getdecltypeformangling.swift b/validation-test/IDE/crashers_fixed/038-swift-mangle-mangler-getdecltypeformangling.swift new file mode 100644 index 00000000000..10df3a6309d --- /dev/null +++ b/validation-test/IDE/crashers_fixed/038-swift-mangle-mangler-getdecltypeformangling.swift @@ -0,0 +1,2 @@ +// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s +struct astruct Bclass B{}struct B diff --git a/validation-test/compiler_crashers/27984-llvm-densemapbase-llvm-densemap-swift-declname.swift b/validation-test/compiler_crashers_fixed/27984-llvm-densemapbase-llvm-densemap-swift-declname.swift similarity index 90% rename from validation-test/compiler_crashers/27984-llvm-densemapbase-llvm-densemap-swift-declname.swift rename to validation-test/compiler_crashers_fixed/27984-llvm-densemapbase-llvm-densemap-swift-declname.swift index 808bf3e7222..9f09ffc098a 100644 --- a/validation-test/compiler_crashers/27984-llvm-densemapbase-llvm-densemap-swift-declname.swift +++ b/validation-test/compiler_crashers_fixed/27984-llvm-densemapbase-llvm-densemap-swift-declname.swift @@ -6,7 +6,7 @@ // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // DUPLICATE-OF: 26832-swift-typechecker-conformstoprotocol.swift -// RUN: not --crash %target-swift-frontend %s -parse +// RUN: not %target-swift-frontend %s -parse class B diff --git a/validation-test/compiler_crashers/28202-swift-typechecker-applygenericarguments.swift b/validation-test/compiler_crashers_fixed/28202-swift-typechecker-applygenericarguments.swift similarity index 89% rename from validation-test/compiler_crashers/28202-swift-typechecker-applygenericarguments.swift rename to validation-test/compiler_crashers_fixed/28202-swift-typechecker-applygenericarguments.swift index 815af2d724b..caf14b1749d 100644 --- a/validation-test/compiler_crashers/28202-swift-typechecker-applygenericarguments.swift +++ b/validation-test/compiler_crashers_fixed/28202-swift-typechecker-applygenericarguments.swift @@ -5,6 +5,6 @@ // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// RUN: not --crash %target-swift-frontend %s -parse +// RUN: not %target-swift-frontend %s -parse // REQUIRES: asserts class Bstruct c:Blet h:A diff --git a/validation-test/compiler_crashers/28269-swift-expr-walk.swift b/validation-test/compiler_crashers_fixed/28269-swift-expr-walk.swift similarity index 88% rename from validation-test/compiler_crashers/28269-swift-expr-walk.swift rename to validation-test/compiler_crashers_fixed/28269-swift-expr-walk.swift index d72c4c14b7f..50dd7b1b733 100644 --- a/validation-test/compiler_crashers/28269-swift-expr-walk.swift +++ b/validation-test/compiler_crashers_fixed/28269-swift-expr-walk.swift @@ -5,6 +5,6 @@ // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// RUN: not --crash %target-swift-frontend %s -parse +// RUN: not %target-swift-frontend %s -parse // REQUIRES: asserts protocol A.struct B