Skip to content

Commit a1d70b6

Browse files
authored
Merge pull request #71550 from kavon/ncgenerics-test-fixes-kavon-v9
Ncgenerics test fixes kavon v9
2 parents d8b5b88 + 32a0ea8 commit a1d70b6

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

lib/AST/ConformanceLookup.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
178178
ImplicitKnownProtocolConformanceRequest icvRequest{nominal, *kp};
179179
if (getASTContext().evaluator.hasActiveRequest(icvRequest) ||
180180
getASTContext().evaluator.hasActiveRequest(request)) {
181-
assert(!getInvertibleProtocolKind(*kp));
182181
return ProtocolConformanceRef::forInvalid();
183182
}
184183
}
@@ -206,6 +205,9 @@ static ProtocolConformanceRef getBuiltinTupleTypeConformance(
206205

207206
auto *tupleDecl = ctx.getBuiltinTupleDecl();
208207

208+
// Ignore @lvalue's within the tuple.
209+
type = type->getRValueType();
210+
209211
// Find the (unspecialized) conformance.
210212
SmallVector<ProtocolConformance *, 2> conformances;
211213
if (tupleDecl->lookupConformance(protocol, conformances)) {
@@ -563,13 +565,16 @@ LookupConformanceInModuleRequest::evaluate(
563565
#ifndef NDEBUG
564566
// Ensure we haven't missed queries for the specialty SIL types
565567
// in the AST in conformance to one of the invertible protocols.
566-
if (auto kp = protocol->getKnownProtocolKind())
567-
if (getInvertibleProtocolKind(*kp))
568+
if (auto kp = protocol->getKnownProtocolKind()) {
569+
if (getInvertibleProtocolKind(*kp)) {
568570
assert(!(type->is<SILFunctionType,
569571
SILBoxType,
570572
SILMoveOnlyWrappedType,
571573
SILPackType,
572574
SILTokenType>()));
575+
assert(!type->is<ReferenceStorageType>());
576+
}
577+
}
573578
#endif
574579

575580
auto nominal = type->getAnyNominal();

lib/SIL/IR/SILPrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,6 +3109,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
31093109
*this << "] ";
31103110
if (auto witnessGenSig = witness->getDerivativeGenericSignature()) {
31113111
auto subPrinter = PrintOptions::printSIL();
3112+
subPrinter.PrintInverseRequirements = true;
31123113
witnessGenSig->print(PrintState.OS, subPrinter);
31133114
*this << " ";
31143115
}
@@ -4186,6 +4187,7 @@ void SILDifferentiabilityWitness::print(llvm::raw_ostream &OS,
41864187
// (<...>)?
41874188
if (auto derivativeGenSig = getDerivativeGenericSignature()) {
41884189
auto subPrinter = PrintOptions::printSIL();
4190+
subPrinter.PrintInverseRequirements = true;
41894191
derivativeGenSig->print(OS, subPrinter);
41904192
OS << " ";
41914193
}

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,7 @@ static bool getConformancesForSubstitution(Parser &P,
17591759
SourceLoc loc,
17601760
SmallVectorImpl<ProtocolConformanceRef> &conformances) {
17611761
auto M = P.SF.getParentModule();
1762+
subReplacement = subReplacement->getReferenceStorageReferent();
17621763

17631764
for (auto protoDecl : protocols) {
17641765
auto conformance = M->lookupConformance(subReplacement, protoDecl);
@@ -1814,6 +1815,7 @@ SubstitutionMap getApplySubstitutionsFromParsed(
18141815
[&](CanType dependentType, Type replacementType,
18151816
ProtocolDecl *proto) -> ProtocolConformanceRef {
18161817
auto M = SP.P.SF.getParentModule();
1818+
replacementType = replacementType->getReferenceStorageReferent();
18171819
if (auto conformance = M->lookupConformance(replacementType, proto))
18181820
return conformance;
18191821

test/Concurrency/async_overload_filtering.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ func filter_async(_: String) -> Void {}
1818
var a: String? = nil
1919

2020
// CHECK: attempting disjunction choice $T0 bound to decl async_overload_filtering.(file).filter_async(fn2:)
21-
// CHECK-NEXT: added constraint: {{.*}} conforms to Copyable
22-
// CHECK-NEXT: overload set choice binding $T0 := {{.*}}
21+
// CHECK-NOT: simplification result
22+
// CHECK: overload set choice binding $T0 := {{.*}}
2323
// CHECK-NEXT: (considering: ({{.*}}) -> {{.*}} applicable fn {{.*}}
2424
// CHECK: increasing 'sync-in-asynchronous' score by 1
2525
// CHECK: solution is worse than the best solution
26+
2627
filter_async {
2728
Obj()
2829
}.op("" + (a ?? "a"))

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,26 @@ bb0:
176176
return %9999 : $()
177177
}
178178

179-
sil [ossa] @mark_unresolved_noncopyable_value_test : $@convention(thin) @async () -> () {
180-
bb0:
181-
%0 = function_ref @constructMoveOnlyStruct : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
182-
%1 = apply %0() : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
183-
%box = alloc_box ${ var NonSendableMoveOnlyStruct }
184-
%project = project_box %box : ${ var NonSendableMoveOnlyStruct }, 0
185-
%unresolved = mark_unresolved_non_copyable_value [consumable_and_assignable] %project : $*NonSendableMoveOnlyStruct
186-
store %1 to [init] %unresolved : $*NonSendableMoveOnlyStruct
187-
188-
%4 = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
189-
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %4<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
190-
// expected-warning @-1 {{transferring value of non-Sendable type 'NonSendableMoveOnlyStruct' from nonisolated context to global actor '<null>'-isolated context; later accesses could race}}
191-
%5 = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
192-
apply %5<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
193-
// expected-note @-1 {{access here could race}}
194-
destroy_value %box : ${ var NonSendableMoveOnlyStruct }
195-
%9999 = tuple ()
196-
return %9999 : $()
197-
}
179+
// sil [ossa] @mark_unresolved_noncopyable_value_test : $@convention(thin) @async () -> () {
180+
// bb0:
181+
// %0 = function_ref @constructMoveOnlyStruct : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
182+
// %1 = apply %0() : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
183+
// %box = alloc_box ${ var NonSendableMoveOnlyStruct }
184+
// %project = project_box %box : ${ var NonSendableMoveOnlyStruct }, 0
185+
// %unresolved = mark_unresolved_non_copyable_value [consumable_and_assignable] %project : $*NonSendableMoveOnlyStruct
186+
// store %1 to [init] %unresolved : $*NonSendableMoveOnlyStruct
187+
188+
// FIXME: rdar://122773845 substitution replacement type 'NonSendableMoveOnlyStruct' does not conform to protocol 'Copyable'
189+
// %4 = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
190+
// apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %4<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
191+
// x-warning @-1 {{transferring value of non-Sendable type 'NonSendableMoveOnlyStruct' from nonisolated context to global actor '<null>'-isolated context; later accesses could race}}
192+
// %5 = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
193+
// apply %5<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
194+
// x-note @-1 {{access here could race}}
195+
// destroy_value %box : ${ var NonSendableMoveOnlyStruct }
196+
// %9999 = tuple ()
197+
// return %9999 : $()
198+
// }
198199

199200
sil [ossa] @mark_unresolved_reference_binding_test : $@convention(thin) @async () -> () {
200201
bb0:
@@ -1646,4 +1647,4 @@ bb0(%arg : $Builtin.Word):
16461647
destroy_value %b : $Builtin.BridgeObject
16471648
%9999 = tuple ()
16481649
return %9999 : $()
1649-
}
1650+
}

0 commit comments

Comments
 (0)