Skip to content

Commit 3fa6084

Browse files
committed
[Runtime] Opt-in for runtime conformance collision warnings.
Make the new runtime conformance collision warnings opt-it, via the environment variable SWIFT_ENABLE_CONFLICTING_CONFORMANCES_CHECK.
1 parent 1c32ea8 commit 3fa6084

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,11 @@ namespace {
583583
};
584584
}
585585

586+
static bool shouldWarnAboutConflictingConformances() {
587+
return SWIFT_LAZY_CONSTANT(
588+
(bool)getenv("SWIFT_ENABLE_CONFLICTING_CONFORMANCES_CHECK"));
589+
}
590+
586591
const ProtocolConformanceDescriptor *
587592
swift::_conformsToSwiftProtocol(const Metadata * const type,
588593
const ProtocolDescriptor *protocol,
@@ -733,7 +738,7 @@ swift::_conformsToSwiftProtocol(const Metadata * const type,
733738
// If we have only retroactive conformances, complain about the
734739
// conflict.
735740
// FIXME: Only do this once per type descriptor/protocol combination.
736-
if (!foundNonRetroactive) {
741+
if (!foundNonRetroactive && shouldWarnAboutConflictingConformances()) {
737742
// Form the list of modules in which we found retroactive conformances.
738743
std::string moduleNamesStr;
739744
const char *firstModuleName = nullptr;

test/Runtime/multiple_conformances.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: %target-build-swift -parse-as-library -force-single-frontend-invocation -I %t %S/Inputs/RetroactiveB.swift -emit-module-path %t/RetroactiveB.swiftmodule -emit-object -o %t/RetroactiveB.o
55
// RUN: %target-build-swift -I %t %s %t/RetroactiveCommon.o %t/RetroactiveA.o %t/RetroactiveB.o -module-name main -o %t/a.out
66
// RUN: %target-codesign %t/a.out
7-
// RUN: %target-run %t/a.out > %t.log 2>&1
7+
// RUN: env SWIFT_ENABLE_CONFLICTING_CONFORMANCES_CHECK=1 %target-run %t/a.out > %t.log 2>&1
88
// RUN: %FileCheck %s < %t.log
99

1010
// REQUIRES: executable_test

0 commit comments

Comments
 (0)