Skip to content

Ncgenerics test fixes kavon v9 #71550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/AST/ConformanceLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
ImplicitKnownProtocolConformanceRequest icvRequest{nominal, *kp};
if (getASTContext().evaluator.hasActiveRequest(icvRequest) ||
getASTContext().evaluator.hasActiveRequest(request)) {
assert(!getInvertibleProtocolKind(*kp));
return ProtocolConformanceRef::forInvalid();
}
}
Expand Down Expand Up @@ -206,6 +205,9 @@ static ProtocolConformanceRef getBuiltinTupleTypeConformance(

auto *tupleDecl = ctx.getBuiltinTupleDecl();

// Ignore @lvalue's within the tuple.
type = type->getRValueType();

// Find the (unspecialized) conformance.
SmallVector<ProtocolConformance *, 2> conformances;
if (tupleDecl->lookupConformance(protocol, conformances)) {
Expand Down Expand Up @@ -563,13 +565,16 @@ LookupConformanceInModuleRequest::evaluate(
#ifndef NDEBUG
// Ensure we haven't missed queries for the specialty SIL types
// in the AST in conformance to one of the invertible protocols.
if (auto kp = protocol->getKnownProtocolKind())
if (getInvertibleProtocolKind(*kp))
if (auto kp = protocol->getKnownProtocolKind()) {
if (getInvertibleProtocolKind(*kp)) {
assert(!(type->is<SILFunctionType,
SILBoxType,
SILMoveOnlyWrappedType,
SILPackType,
SILTokenType>()));
assert(!type->is<ReferenceStorageType>());
}
}
#endif

auto nominal = type->getAnyNominal();
Expand Down
2 changes: 2 additions & 0 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
*this << "] ";
if (auto witnessGenSig = witness->getDerivativeGenericSignature()) {
auto subPrinter = PrintOptions::printSIL();
subPrinter.PrintInverseRequirements = true;
witnessGenSig->print(PrintState.OS, subPrinter);
*this << " ";
}
Expand Down Expand Up @@ -4186,6 +4187,7 @@ void SILDifferentiabilityWitness::print(llvm::raw_ostream &OS,
// (<...>)?
if (auto derivativeGenSig = getDerivativeGenericSignature()) {
auto subPrinter = PrintOptions::printSIL();
subPrinter.PrintInverseRequirements = true;
derivativeGenSig->print(OS, subPrinter);
OS << " ";
}
Expand Down
2 changes: 2 additions & 0 deletions lib/SIL/Parser/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,7 @@ static bool getConformancesForSubstitution(Parser &P,
SourceLoc loc,
SmallVectorImpl<ProtocolConformanceRef> &conformances) {
auto M = P.SF.getParentModule();
subReplacement = subReplacement->getReferenceStorageReferent();

for (auto protoDecl : protocols) {
auto conformance = M->lookupConformance(subReplacement, protoDecl);
Expand Down Expand Up @@ -1814,6 +1815,7 @@ SubstitutionMap getApplySubstitutionsFromParsed(
[&](CanType dependentType, Type replacementType,
ProtocolDecl *proto) -> ProtocolConformanceRef {
auto M = SP.P.SF.getParentModule();
replacementType = replacementType->getReferenceStorageReferent();
if (auto conformance = M->lookupConformance(replacementType, proto))
return conformance;

Expand Down
5 changes: 3 additions & 2 deletions test/Concurrency/async_overload_filtering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ func filter_async(_: String) -> Void {}
var a: String? = nil

// CHECK: attempting disjunction choice $T0 bound to decl async_overload_filtering.(file).filter_async(fn2:)
// CHECK-NEXT: added constraint: {{.*}} conforms to Copyable
// CHECK-NEXT: overload set choice binding $T0 := {{.*}}
// CHECK-NOT: simplification result
// CHECK: overload set choice binding $T0 := {{.*}}
// CHECK-NEXT: (considering: ({{.*}}) -> {{.*}} applicable fn {{.*}}
// CHECK: increasing 'sync-in-asynchronous' score by 1
// CHECK: solution is worse than the best solution

filter_async {
Obj()
}.op("" + (a ?? "a"))
41 changes: 21 additions & 20 deletions test/Concurrency/transfernonsendable_instruction_matching.sil
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,26 @@ bb0:
return %9999 : $()
}

sil [ossa] @mark_unresolved_noncopyable_value_test : $@convention(thin) @async () -> () {
bb0:
%0 = function_ref @constructMoveOnlyStruct : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
%1 = apply %0() : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
%box = alloc_box ${ var NonSendableMoveOnlyStruct }
%project = project_box %box : ${ var NonSendableMoveOnlyStruct }, 0
%unresolved = mark_unresolved_non_copyable_value [consumable_and_assignable] %project : $*NonSendableMoveOnlyStruct
store %1 to [init] %unresolved : $*NonSendableMoveOnlyStruct

%4 = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %4<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
// expected-warning @-1 {{transferring value of non-Sendable type 'NonSendableMoveOnlyStruct' from nonisolated context to global actor '<null>'-isolated context; later accesses could race}}
%5 = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
apply %5<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
// expected-note @-1 {{access here could race}}
destroy_value %box : ${ var NonSendableMoveOnlyStruct }
%9999 = tuple ()
return %9999 : $()
}
// sil [ossa] @mark_unresolved_noncopyable_value_test : $@convention(thin) @async () -> () {
// bb0:
// %0 = function_ref @constructMoveOnlyStruct : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
// %1 = apply %0() : $@convention(thin) () -> @owned NonSendableMoveOnlyStruct
// %box = alloc_box ${ var NonSendableMoveOnlyStruct }
// %project = project_box %box : ${ var NonSendableMoveOnlyStruct }, 0
// %unresolved = mark_unresolved_non_copyable_value [consumable_and_assignable] %project : $*NonSendableMoveOnlyStruct
// store %1 to [init] %unresolved : $*NonSendableMoveOnlyStruct

// FIXME: rdar://122773845 substitution replacement type 'NonSendableMoveOnlyStruct' does not conform to protocol 'Copyable'
// %4 = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
// apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %4<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
// x-warning @-1 {{transferring value of non-Sendable type 'NonSendableMoveOnlyStruct' from nonisolated context to global actor '<null>'-isolated context; later accesses could race}}
// %5 = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
// apply %5<NonSendableMoveOnlyStruct>(%unresolved) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
// x-note @-1 {{access here could race}}
// destroy_value %box : ${ var NonSendableMoveOnlyStruct }
// %9999 = tuple ()
// return %9999 : $()
// }

sil [ossa] @mark_unresolved_reference_binding_test : $@convention(thin) @async () -> () {
bb0:
Expand Down Expand Up @@ -1646,4 +1647,4 @@ bb0(%arg : $Builtin.Word):
destroy_value %b : $Builtin.BridgeObject
%9999 = tuple ()
return %9999 : $()
}
}