Skip to content

Commit 9c5432c

Browse files
committed
Make __consuming meaningful for code generation.
Previously, the `__consuming` decl modifier failed to get propagated to the value ownership of the method's `self` parameter, causing it to effectively be a no-op. Fix this, and address some of the downstream issues this exposes: - `coerceCallArguments` in the type checker failing to handle the single `__owned` parameter case - Various places in SILGen and optimizer passes that made inappropriate assertions that `self` was always passed guaranteed
1 parent 2125304 commit 9c5432c

File tree

15 files changed

+80
-95
lines changed

15 files changed

+80
-95
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,23 +3646,6 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
36463646
llvm_unreachable("Unhandled Representation in switch.");
36473647
}
36483648

3649-
bool hasGuaranteedSelfParam() const {
3650-
switch (getRepresentation()) {
3651-
case Representation::Thick:
3652-
case Representation::Block:
3653-
case Representation::Thin:
3654-
case Representation::CFunctionPointer:
3655-
case Representation::ObjCMethod:
3656-
case Representation::Closure:
3657-
return false;
3658-
case Representation::Method:
3659-
case Representation::WitnessMethod:
3660-
return true;
3661-
}
3662-
3663-
llvm_unreachable("Unhandled Representation in switch.");
3664-
}
3665-
36663649
/// True if the function representation carries context.
36673650
bool hasContext() const {
36683651
switch (getRepresentation()) {

lib/AST/ASTContext.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,12 +3179,12 @@ AnyFunctionType::Param swift::computeSelfParam(AbstractFunctionDecl *AFD,
31793179
return AnyFunctionType::Param(ErrorType::get(Ctx));
31803180

31813181
bool isStatic = false;
3182-
bool isMutating = false;
3182+
SelfAccessKind selfAccess = SelfAccessKind::NonMutating;
31833183
bool isDynamicSelf = false;
31843184

31853185
if (auto *FD = dyn_cast<FuncDecl>(AFD)) {
31863186
isStatic = FD->isStatic();
3187-
isMutating = FD->isMutating();
3187+
selfAccess = FD->getSelfAccessKind();
31883188

31893189
// Methods returning 'Self' have a dynamic 'self'.
31903190
//
@@ -3195,7 +3195,7 @@ AnyFunctionType::Param swift::computeSelfParam(AbstractFunctionDecl *AFD,
31953195
if (isInitializingCtor) {
31963196
// initializing constructors of value types always have an implicitly
31973197
// inout self.
3198-
isMutating = true;
3198+
selfAccess = SelfAccessKind::Mutating;
31993199
} else {
32003200
// allocating constructors have metatype 'self'.
32013201
isStatic = true;
@@ -3209,8 +3209,11 @@ AnyFunctionType::Param swift::computeSelfParam(AbstractFunctionDecl *AFD,
32093209
isDynamicSelf = true;
32103210
}
32113211
} else if (isa<DestructorDecl>(AFD)) {
3212-
// destructors of value types always have an implicitly inout self.
3213-
isMutating = true;
3212+
// Destructors only correctly appear on classes today. (If move-only types
3213+
// have destructors, they probably would want to consume self.)
3214+
// Note that we can't assert(containerTy->hasReferenceSemantics()) here
3215+
// since incorrect or incomplete code could have deinit decls in invalid
3216+
// contexts, and we need to recover gracefully in those cases.
32143217
}
32153218

32163219
if (isDynamicSelf)
@@ -3224,8 +3227,20 @@ AnyFunctionType::Param swift::computeSelfParam(AbstractFunctionDecl *AFD,
32243227
if (containerTy->hasReferenceSemantics())
32253228
return AnyFunctionType::Param(selfTy);
32263229

3227-
return AnyFunctionType::Param(selfTy, Identifier(),
3228-
ParameterTypeFlags().withInOut(isMutating));
3230+
auto flags = ParameterTypeFlags();
3231+
switch (selfAccess) {
3232+
case SelfAccessKind::__Consuming:
3233+
flags = flags.withOwned(true);
3234+
break;
3235+
case SelfAccessKind::Mutating:
3236+
flags = flags.withInOut(true);
3237+
break;
3238+
case SelfAccessKind::NonMutating:
3239+
// The default flagless state.
3240+
break;
3241+
}
3242+
3243+
return AnyFunctionType::Param(selfTy, Identifier(), flags);
32293244
}
32303245

32313246
void UnboundGenericType::Profile(llvm::FoldingSetNodeID &ID,

lib/SIL/SILFunctionBuilder.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,6 @@ SILFunction *SILFunctionBuilder::getOrCreateFunction(
3434
return fn;
3535
}
3636

37-
static bool verifySILSelfParameterType(SILDeclRef DeclRef, SILFunction *F,
38-
CanSILFunctionType FTy) {
39-
SILModule &M = F->getModule();
40-
SILParameterInfo PInfo = FTy->getSelfParameter();
41-
CanType CTy = PInfo.getType();
42-
SILType Ty = SILType::getPrimitiveObjectType(CTy);
43-
44-
// We do not care about trivial parameters (for now). There seem to be
45-
// cases where we lower them as unowned.
46-
//
47-
// *NOTE* We do not run this check when we have a generic type since
48-
// *generic types do not have type lowering and are always treated as
49-
// *non-trivial since we do not know the type.
50-
if (CTy->hasArchetype() || CTy->hasTypeParameter() ||
51-
M.getTypeLowering(Ty).isTrivial())
52-
return true;
53-
54-
// If this function is a constructor or destructor, bail. These have @owned
55-
// parameters.
56-
if (DeclRef.isConstructor() || DeclRef.isDestructor())
57-
return true;
58-
59-
// Otherwise, if this function type has a guaranteed self parameter type,
60-
// make sure that we have a +0 self param.
61-
return !FTy->getExtInfo().hasGuaranteedSelfParam() || PInfo.isGuaranteed() ||
62-
PInfo.isIndirectMutating();
63-
}
64-
6537
static void addFunctionAttributes(SILFunction *F, DeclAttributes &Attrs,
6638
SILModule &M) {
6739
for (auto *A : Attrs.getAttributes<SemanticsAttr>())
@@ -151,17 +123,6 @@ SILFunctionBuilder::getOrCreateFunction(SILLocation loc, SILDeclRef constant,
151123
addFunctionAttributes(F, decl->getAttrs(), mod);
152124
}
153125

154-
// If this function has a self parameter, make sure that it has a +0 calling
155-
// convention. This cannot be done for general function types, since
156-
// function_ref's SILFunctionTypes do not have archetypes associated with
157-
// it.
158-
CanSILFunctionType FTy = F->getLoweredFunctionType();
159-
if (FTy->hasSelfParam()) {
160-
(void)&verifySILSelfParameterType;
161-
assert(verifySILSelfParameterType(constant, F, FTy) &&
162-
"Invalid signature for SIL Self parameter type");
163-
}
164-
165126
return F;
166127
}
167128

lib/SIL/SILFunctionType.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,8 @@ class DestructureInputs {
689689
if (ownership == ValueOwnership::InOut) {
690690
convention = ParameterConvention::Indirect_Inout;
691691
} else if (isFormallyPassedIndirectly(origType, substType, substTL)) {
692-
if (forSelf && rep == SILFunctionTypeRepresentation::WitnessMethod)
693-
convention = ParameterConvention::Indirect_In_Guaranteed;
694-
else
695-
convention = Convs.getIndirect(ownership, forSelf, origParamIndex,
696-
origType, substTL);
692+
convention = Convs.getIndirect(ownership, forSelf, origParamIndex,
693+
origType, substTL);
697694
assert(isIndirectFormalParameter(convention));
698695
} else if (substTL.isTrivial()) {
699696
convention = ParameterConvention::Direct_Unowned;

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,8 +1517,9 @@ bool LifetimeChecker::diagnoseMethodCall(const DIMemoryUse &Use,
15171517
// the generic error that we would emit before.
15181518
//
15191519
// That is the only case where we support pattern matching a release.
1520-
if (Release && AI &&
1521-
!AI->getSubstCalleeType()->getExtInfo().hasGuaranteedSelfParam())
1520+
if (Release && AI /*
1521+
&& (!AI->getSubstCalleeType()->hasSelfParam()
1522+
|| !AI->getSubstCalleeType()->getSelfParameter().isGuaranteed())*/)
15221523
MI = nullptr;
15231524

15241525
if (AI && MI) {

lib/Sema/CSApply.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5753,6 +5753,17 @@ Expr *ExprRewriter::coerceCallArguments(
57535753
// If we came from a scalar, create a scalar-to-tuple conversion.
57545754
TupleShuffleExpr::TypeImpact typeImpact;
57555755
if (argTuple == nullptr) {
5756+
// Deal with a difference in only scalar ownership.
5757+
if (auto paramParenTy = dyn_cast<ParenType>(paramType.getPointer())) {
5758+
assert(paramParenTy->getUnderlyingType()
5759+
->isEqual(cs.getType(arg)));
5760+
auto argParen = new (tc.Context) ParenExpr(arg->getStartLoc(),
5761+
arg, arg->getEndLoc(), false,
5762+
paramParenTy);
5763+
argParen->setImplicit();
5764+
return cs.cacheType(argParen);
5765+
}
5766+
57565767
typeImpact = TupleShuffleExpr::ScalarToTuple;
57575768
assert(isa<TupleType>(paramType.getPointer()));
57585769
} else if (isa<TupleType>(paramType.getPointer())) {

test/SILGen/foreach.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ func trivialStructBreak(_ xx: [Int]) {
110110
// CHECK: [[ITERATOR_BOX:%.*]] = alloc_box ${ var IndexingIterator<Array<Int>> }, var, name "$x$generator"
111111
// CHECK: [[PROJECT_ITERATOR_BOX:%.*]] = project_box [[ITERATOR_BOX]]
112112
// CHECK: [[BORROWED_ARRAY_STACK:%.*]] = alloc_stack $Array<Int>
113-
// CHECK: store_borrow [[ARRAY]] to [[BORROWED_ARRAY_STACK]]
114-
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in_guaranteed τ_0_0) -> @out IndexingIterator<τ_0_0>
113+
// CHECK: store [[ARRAY_COPY:%.*]] to [init] [[BORROWED_ARRAY_STACK]]
114+
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF
115115
// CHECK: apply [[MAKE_ITERATOR_FUNC]]<[Int]>([[PROJECT_ITERATOR_BOX]], [[BORROWED_ARRAY_STACK]])
116116
// CHECK: br [[LOOP_DEST:bb[0-9]+]]
117117
//
@@ -213,8 +213,8 @@ func existentialBreak(_ xx: [P]) {
213213
// CHECK: [[ITERATOR_BOX:%.*]] = alloc_box ${ var IndexingIterator<Array<P>> }, var, name "$x$generator"
214214
// CHECK: [[PROJECT_ITERATOR_BOX:%.*]] = project_box [[ITERATOR_BOX]]
215215
// CHECK: [[BORROWED_ARRAY_STACK:%.*]] = alloc_stack $Array<P>
216-
// CHECK: store_borrow [[ARRAY]] to [[BORROWED_ARRAY_STACK]]
217-
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in_guaranteed τ_0_0) -> @out IndexingIterator<τ_0_0>
216+
// CHECK: store [[ARRAY_COPY:%.*]] to [init] [[BORROWED_ARRAY_STACK]]
217+
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF
218218
// CHECK: apply [[MAKE_ITERATOR_FUNC]]<[P]>([[PROJECT_ITERATOR_BOX]], [[BORROWED_ARRAY_STACK]])
219219
// CHECK: [[ELT_STACK:%.*]] = alloc_stack $Optional<P>
220220
// CHECK: br [[LOOP_DEST:bb[0-9]+]]
@@ -376,8 +376,8 @@ func genericStructBreak<T>(_ xx: [GenericStruct<T>]) {
376376
// CHECK: [[ITERATOR_BOX:%.*]] = alloc_box $<τ_0_0> { var IndexingIterator<Array<GenericStruct<τ_0_0>>> } <T>, var, name "$x$generator"
377377
// CHECK: [[PROJECT_ITERATOR_BOX:%.*]] = project_box [[ITERATOR_BOX]]
378378
// CHECK: [[BORROWED_ARRAY_STACK:%.*]] = alloc_stack $Array<GenericStruct<T>>
379-
// CHECK: store_borrow [[ARRAY]] to [[BORROWED_ARRAY_STACK]]
380-
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in_guaranteed τ_0_0) -> @out IndexingIterator<τ_0_0>
379+
// CHECK: store [[ARRAY_COPY:%.*]] to [init] [[BORROWED_ARRAY_STACK]]
380+
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF
381381
// CHECK: apply [[MAKE_ITERATOR_FUNC]]<[GenericStruct<T>]>([[PROJECT_ITERATOR_BOX]], [[BORROWED_ARRAY_STACK]])
382382
// CHECK: [[ELT_STACK:%.*]] = alloc_stack $Optional<GenericStruct<T>>
383383
// CHECK: br [[LOOP_DEST:bb[0-9]+]]
@@ -486,8 +486,8 @@ func genericCollectionBreak<T : Collection>(_ xx: T) {
486486
// CHECK: bb0([[COLLECTION:%.*]] : @trivial $*T):
487487
// CHECK: [[ITERATOR_BOX:%.*]] = alloc_box $<τ_0_0 where τ_0_0 : Collection> { var τ_0_0.Iterator } <T>, var, name "$x$generator"
488488
// CHECK: [[PROJECT_ITERATOR_BOX:%.*]] = project_box [[ITERATOR_BOX]]
489-
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = witness_method $T, #Sequence.makeIterator!1 : <Self where Self : Sequence> (Self) -> () -> Self.Iterator : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in_guaranteed τ_0_0) -> @out τ_0_0.Iterator
490-
// CHECK: apply [[MAKE_ITERATOR_FUNC]]<T>([[PROJECT_ITERATOR_BOX]], [[COLLECTION]])
489+
// CHECK: [[MAKE_ITERATOR_FUNC:%.*]] = witness_method $T, #Sequence.makeIterator!1
490+
// CHECK: apply [[MAKE_ITERATOR_FUNC]]<T>([[PROJECT_ITERATOR_BOX]], [[COLLECTION_COPY:%.*]])
491491
// CHECK: [[ELT_STACK:%.*]] = alloc_stack $Optional<T.Element>
492492
// CHECK: br [[LOOP_DEST:bb[0-9]+]]
493493
//

test/SILGen/value_ownership.swift

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,56 @@ protocol OwnershipProto {
44
__consuming func elided(_ default: String, _ shared: __shared String, _ owned: __owned String)
55

66
__consuming func explicit(_ default: String, _ shared: __shared String, _ owned: __owned String)
7+
8+
var elidedPropertyGet: String { __consuming get }
9+
var explicitPropertyGet: String { __consuming get }
710
}
811

912
struct Witness: OwnershipProto {
13+
var x: String
14+
1015
func elided(_ default: String, _ shared: String, _ owned: String) { }
1116

1217
__consuming func explicit(_ default: String, _ toShared: __shared String, _ toOwned: __owned String) { }
18+
19+
var elidedPropertyGet: String { return "" }
20+
var explicitPropertyGet: String { __consuming get { return "" } }
1321
}
1422

1523
// Check the conventions of the witnesses
1624

17-
// CHECK-LABEL: sil hidden @$s15value_ownership7WitnessV6elidedyySS_S2StF : $@convention(method) (@guaranteed String, @guaranteed String, @guaranteed String, Witness) -> () {
18-
// CHECK: } // end sil function '$s15value_ownership7WitnessV6elidedyySS_S2StF'
19-
20-
// CHECK-LABEL: sil hidden @$s15value_ownership7WitnessV8explicityySS_SShSSntF : $@convention(method) (@guaranteed String, @guaranteed String, @owned String, Witness) -> () {
21-
// CHECK: } // end sil function '$s15value_ownership7WitnessV8explicityySS_SShSSntF'
25+
// CHECK-LABEL: sil hidden @$s15value_ownership7WitnessV6elidedyySS_S2StF : $@convention(method) (@guaranteed String, @guaranteed String, @guaranteed String, @guaranteed Witness) -> () {
26+
// CHECK-LABEL: sil hidden @$s15value_ownership7WitnessV8explicityySS_SShSSntF : $@convention(method) (@guaranteed String, @guaranteed String, @owned String, @owned Witness) -> () {
27+
// CHECK-LABEL: sil hidden @$s15value_ownership7WitnessV17elidedPropertyGetSSvg : $@convention(method) (@guaranteed Witness) -> @owned String
28+
// CHECK-LABEL: sil hidden @$s15value_ownership7WitnessV19explicitPropertyGetSSvg : $@convention(method) (@owned Witness) -> @owned String
2229

2330
// Check the elided witness' thunk has the right conventions and borrows where necessary
2431

25-
// CHECK-LABEL: @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP6elidedyySS_SShSSntFTW : $@convention(witness_method: OwnershipProto) (@guaranteed String, @guaranteed String, @owned String, @in_guaranteed Witness) -> ()
32+
// CHECK-LABEL: @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP6elidedyySS_SShSSntFTW : $@convention(witness_method: OwnershipProto) (@guaranteed String, @guaranteed String, @owned String, @in Witness) -> ()
2633
// CHECK: bb0([[DEFAULT2DEFAULT:%.*]] : @guaranteed $String, [[SHARED2DEFAULT:%.*]] : @guaranteed $String, [[OWNED2DEFAULT:%.*]] : @owned $String, [[WITNESS_VALUE:%.*]] : @trivial $*Witness):
27-
// CHECK: [[LOAD_WITNESS:%.*]] = load [trivial] [[WITNESS_VALUE]] : $*Witness
34+
// CHECK: [[LOAD_WITNESS:%.*]] = load [take] [[WITNESS_VALUE]] : $*Witness
35+
// CHECK: [[BORROW_WITNESS:%.*]] = begin_borrow [[LOAD_WITNESS]]
2836
// CHECK: [[WITNESS_FUNC:%.*]] = function_ref @$s15value_ownership7WitnessV6elidedyySS_S2StF
2937
// CHECK: [[BORROWOWNED2DEFAULT:%.*]] = begin_borrow [[OWNED2DEFAULT]] : $String
30-
// CHECK: apply [[WITNESS_FUNC]]([[DEFAULT2DEFAULT]], [[SHARED2DEFAULT]], [[BORROWOWNED2DEFAULT]], [[LOAD_WITNESS]])
38+
// CHECK: apply [[WITNESS_FUNC]]([[DEFAULT2DEFAULT]], [[SHARED2DEFAULT]], [[BORROWOWNED2DEFAULT]], [[BORROW_WITNESS]])
3139
// CHECK: end_borrow [[BORROWOWNED2DEFAULT]] : $String
40+
// CHECK: end_borrow [[BORROW_WITNESS]]
41+
// CHECK: destroy_value [[LOAD_WITNESS]]
3242
// CHECK: } // end sil function '$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP6elidedyySS_SShSSntFTW'
3343

3444
// Check that the explicit witness' thunk doesn't copy or borrow
3545

36-
// CHECK-LABEL: @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP8explicityySS_SShSSntFTW : $@convention(witness_method: OwnershipProto) (@guaranteed String, @guaranteed String, @owned String, @in_guaranteed Witness) -> () {
46+
// CHECK-LABEL: @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP8explicityySS_SShSSntFTW : $@convention(witness_method: OwnershipProto) (@guaranteed String, @guaranteed String, @owned String, @in Witness) -> () {
3747
// CHECK: bb0([[ARG0:%.*]] : @guaranteed $String, [[ARG1:%.*]] : @guaranteed $String, [[ARG2:%.*]] : @owned $String, [[WITNESS_VALUE:%.*]] : @trivial $*Witness):
38-
// CHECK-NEXT: [[LOAD_WITNESS:%.*]] = load [trivial] [[WITNESS_VALUE]] : $*Witness
48+
// CHECK-NEXT: [[LOAD_WITNESS:%.*]] = load [take] [[WITNESS_VALUE]] : $*Witness
3949
// CHECK-NEXT: // function_ref Witness.explicit(_:_:_:)
4050
// CHECK-NEXT: [[WITNESS_FUNC:%.*]] = function_ref @$s15value_ownership7WitnessV8explicityySS_SShSSntF
4151
// CHECK-NEXT: apply [[WITNESS_FUNC]]([[ARG0]], [[ARG1]], [[ARG2]], [[LOAD_WITNESS]])
4252
// CHECK: } // end sil function '$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP8explicityySS_SShSSntFTW'
53+
54+
// Check the signature of the property accessor witness thunks.
55+
// If a protocol asks for a __consuming get it should get a +1-in +1-out
56+
// accessor entry point in its witness table.
57+
58+
// CHECK-LABEL: sil private [transparent] [thunk] @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP17elidedPropertyGetSSvgTW : $@convention(witness_method: OwnershipProto) (@in Witness) -> @owned String
59+
// CHECK-LABEL: sil private [transparent] [thunk] @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP19explicitPropertyGetSSvgTW : $@convention(witness_method: OwnershipProto) (@in Witness) -> @owned String

test/SILGen/witness_same_type.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Foo: Fooable {
2020
}
2121

2222
// rdar://problem/19049566
23-
// CHECK-LABEL: sil shared [transparent] [serialized] [thunk] @$s17witness_same_type14LazySequenceOfVyxq_GSTAAST12makeIterator0H0QzyFTW : $@convention(witness_method: Sequence) <τ_0_0, τ_0_1 where τ_0_0 : Sequence, τ_0_1 == τ_0_0.Element> (@in_guaranteed LazySequenceOf<τ_0_0, τ_0_1>) -> @out AnyIterator<τ_0_1>
23+
// CHECK-LABEL: sil shared [transparent] [serialized] [thunk] @$s17witness_same_type14LazySequenceOfVyxq_GSTAAST12makeIterator0H0QzyFTW : $@convention(witness_method: Sequence) <τ_0_0, τ_0_1 where τ_0_0 : Sequence, τ_0_1 == τ_0_0.Element> (@in LazySequenceOf<τ_0_0, τ_0_1>) -> @out AnyIterator<τ_0_1>
2424
public struct LazySequenceOf<SS : Sequence, A> : Sequence where SS.Iterator.Element == A {
2525
public func makeIterator() -> AnyIterator<A> {
2626
var opt: AnyIterator<A>?

test/Sema/fixed_ambiguities/rdar27033993.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class S {}
44
let arr: [(S, Int)] = []
55
let _: [S] = arr.sorted {
66
$0.1 < $1.1
7-
// CHECK: function_ref @$sSlsE6prefixy11SubSequenceQzSiF : $@convention(method) <τ_0_0 where τ_0_0 : Collection> (Int, @in_guaranteed τ_0_0) -> @out τ_0_0.SubSequence
7+
// CHECK: function_ref @$sSlsE6prefixy11SubSequenceQzSiF
88
}.prefix(1).map {
99
return $0.0
1010
}

test/Sema/fixed_ambiguities/rdar27198177.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
let arr = ["A", "B", "C"]
55
let lazy: LazyMapCollection = arr.lazy.map { $0 }
6-
// CHECK: function_ref @$ss22LazyCollectionProtocolPsE6filterys0a6FilterB0Vy8ElementsQzGSb7ElementQzcF : $@convention(method) <τ_0_0 where τ_0_0 : LazyCollectionProtocol> (@guaranteed @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> Bool, @in_guaranteed τ_0_0) -> @out LazyFilterCollection<τ_0_0.Elements>
6+
// CHECK: function_ref @$ss22LazyCollectionProtocolPsE6filterys0a6FilterB0Vy8ElementsQzGSb7ElementQzcF
77
_ = lazy.filter { $0 > "A" }.count

test/Sema/fixed_ambiguities/rdar33142386.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// RUN: %target-swift-frontend -emit-sil -verify %s -swift-version 4 | %FileCheck %s
33

44
let x: String = "ultimate question"
5-
// CHECK: function_ref @$sSmsE6filteryxSb7ElementQzKXEKF : $@convention(method) <τ_0_0 where τ_0_0 : RangeReplaceableCollection> (@noescape @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> (Bool, @error Error), @in_guaranteed τ_0_0) -> (@out τ_0_0, @error Error)
5+
// CHECK: function_ref @$sSmsE6filteryxSb7ElementQzKXEKF
66
_ = x.filter({ $0 == " " }).count < 3

test/Sema/fixed_ambiguities/rdar35624855.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
extension Collection {
44
func foo() {
5-
// CHECK: witness_method $Self.Indices, #Sequence.dropFirst!1 : <Self where Self : Sequence> (Self) -> (Int) -> Self.SubSequence : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (Int, @in_guaranteed τ_0_0) -> @out τ_0_0.SubSequence
5+
// CHECK: witness_method $Self.Indices, #Sequence.dropFirst!1
66
_ = zip(indices, indices.dropFirst(3))
77
}
88
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
22
let arr = Array(10...20)
3-
// CHECK: function_ref @$sSlsE6prefixy11SubSequenceQzSiF : $@convention(method) <τ_0_0 where τ_0_0 : Collection> (Int, @in_guaranteed τ_0_0) -> @out τ_0_0.SubSequence
3+
// CHECK: function_ref @$sSlsE6prefixy11SubSequenceQzSiF
44
arr.prefix(3).forEach { (v: Int) in }

0 commit comments

Comments
 (0)