Skip to content

Commit 906d261

Browse files
authored
Merge pull request #71395 from kavon/ncgenerics-test-fixes-kavon-v2
NCGenerics: more test fixes (v2)
2 parents 4cd167c + ee12fd6 commit 906d261

File tree

7 files changed

+42
-13
lines changed

7 files changed

+42
-13
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,9 +1581,16 @@ bestRequirementPrintLocation(ProtocolDecl *proto, const Requirement &req) {
15811581

15821582
void PrintAST::printInheritedFromRequirementSignature(ProtocolDecl *proto,
15831583
TypeDecl *attachingTo) {
1584+
unsigned flags = PrintInherited;
1585+
1586+
// The invertible protocols themselves do not need to state inverses in their
1587+
// inheritance clause, because they do not gain any default requirements.
1588+
if (!proto->getInvertibleProtocolKind())
1589+
flags |= PrintInverseRequirements;
1590+
15841591
printRequirementSignature(
15851592
proto, proto->getRequirementSignature(),
1586-
PrintInherited | PrintInverseRequirements,
1593+
flags,
15871594
attachingTo);
15881595
}
15891596

lib/AST/ConformanceLookup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ static bool conformsToInvertible(CanType type, InvertibleProtocolKind ip) {
831831
// Must not have a type parameter!
832832
assert(!type->hasTypeParameter() && "caller forgot to mapTypeIntoContext!");
833833

834+
assert(!type->hasUnboundGenericType() && "a UGT has no conformances!");
835+
834836
assert(!type->is<PackExpansionType>());
835837

836838
// The SIL types in the AST do not have real conformances, and should have

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,9 +2641,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
26412641
if (Args.hasArg(OPT_no_clang_module_breadcrumbs))
26422642
Opts.DisableClangModuleSkeletonCUs = true;
26432643

2644-
if (SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS)
2645-
Opts.DisableRoundTripDebugTypes = true; // temporary until we fix mangling!
2646-
26472644
if (auto A = Args.getLastArg(OPT_enable_round_trip_debug_types,
26482645
OPT_disable_round_trip_debug_types)) {
26492646
Opts.DisableRoundTripDebugTypes =

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
18171817
// Emit the protocols the archetypes conform to.
18181818
SmallVector<llvm::Metadata *, 4> Protocols;
18191819
for (auto *ProtocolDecl : Archetype->getConformsTo()) {
1820+
// Skip marker protocols, as they are not available at runtime.
1821+
if (ProtocolDecl->isMarkerProtocol())
1822+
continue;
1823+
18201824
auto PTy =
18211825
IGM.getLoweredType(ProtocolDecl->getInterfaceType()).getASTType();
18221826
auto PDbgTy = DebugTypeInfo::getFromTypeInfo(

lib/Sema/TypeCheckDecl.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -927,13 +927,12 @@ InvertibleAnnotationRequest::evaluate(Evaluator &evaluator,
927927

928928
switch (TARGET) {
929929
case InvertibleProtocolKind::Copyable:
930-
// Handle the legacy '@_moveOnly' attribute
931-
if (auto attr = decl->getAttrs().getAttribute<MoveOnlyAttr>()) {
932-
assert((isa<StructDecl, EnumDecl, ClassDecl>(decl)));
933-
934-
return InverseMarking::forInverse(Kind::LegacyExplicit,
935-
attr->getLocation());
936-
}
930+
// Handle the legacy '@_moveOnly' for types they can validly appear.
931+
// TypeCheckAttr handles the illegal situations for us.
932+
if (auto attr = decl->getAttrs().getAttribute<MoveOnlyAttr>())
933+
if (isa<StructDecl, EnumDecl, ClassDecl>(decl))
934+
return InverseMarking::forInverse(Kind::LegacyExplicit,
935+
attr->getLocation());
937936
break;
938937

939938
case InvertibleProtocolKind::Escapable:
@@ -2559,7 +2558,8 @@ static Type validateParameterType(ParamDecl *decl) {
25592558
}
25602559

25612560
// Validate the presence of ownership for a parameter with an inverse applied.
2562-
if (diagnoseMissingOwnership(ctx, dc, ownership,
2561+
if (!Ty->hasUnboundGenericType() &&
2562+
diagnoseMissingOwnership(ctx, dc, ownership,
25632563
decl->getTypeRepr(), Ty, options)) {
25642564
decl->setInvalid();
25652565
return ErrorType::get(ctx);

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ function(_compile_swift_files
610610
if(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS)
611611
list(APPEND swift_flags "-enable-experimental-feature" "NoncopyableGenerics")
612612
list(APPEND swift_flags "-Xfrontend" "-enable-experimental-associated-type-inference")
613-
list(APPEND swift_flags "-Xfrontend" "-disable-round-trip-debug-types") # NOTE: temporary until we fix mangling!
614613
endif()
615614

616615
if (SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend %s \
2+
// RUN: -swift-version 5 \
3+
// RUN: -enable-library-evolution \
4+
// RUN: -emit-module -module-name Swift -parse-stdlib \
5+
// RUN: -enable-experimental-feature NoncopyableGenerics \
6+
// RUN: -o %t/Swift.swiftmodule \
7+
// RUN: -emit-module-interface-path %t/Swift.swiftinterface
8+
9+
// RUN: %FileCheck %s < %t/Swift.swiftinterface
10+
11+
// CHECK-DAG: @_marker public protocol Copyable {
12+
// CHECK-DAG: @_marker public protocol Escapable {
13+
14+
// This test verifies that:
15+
// 1. When omitted, the an invertible protocol decl gets automatically
16+
// synthesized into a module named Swift
17+
// 2. These protocol decls do not specify inverses in their inheritance clause
18+
// when emitted into the interface file.
19+
20+
@_marker public protocol Escapable { }

0 commit comments

Comments
 (0)