Skip to content

Commit 17878df

Browse files
committed
---
yaml --- r: 346015 b: refs/heads/master c: 8f70d56 h: refs/heads/master i: 346013: 6874258 346011: 52b867c 346007: ed6ae4b 345999: 22a72d0 345983: bc741be
1 parent c1a4385 commit 17878df

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 058e7ea750d60cb8a9a76d2cb0f6eb45eb518f94
2+
refs/heads/master: 8f70d56a325a9f5138cc439cfc08b88da2754663
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ function(_add_variant_c_compile_flags)
265265
# Emulate /GR-.
266266
# TODO(compnerd) when moving up to VS 2017 15.3 and newer, we can disable
267267
# RTTI again
268-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
268+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
269+
list(APPEND result /GR-)
270+
else()
269271
list(APPEND result -frtti)
270272
list(APPEND result -Xclang;-fno-rtti-data)
271273
endif()

trunk/lib/Frontend/ParseableInterfaceSupport.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swift/AST/ExistentialLayout.h"
1818
#include "swift/AST/FileSystem.h"
1919
#include "swift/AST/Module.h"
20+
#include "swift/AST/ProtocolConformance.h"
2021
#include "swift/Frontend/Frontend.h"
2122
#include "swift/Frontend/ParseableInterfaceSupport.h"
2223
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
@@ -657,12 +658,26 @@ class InheritedProtocolCollector {
657658
// No recursion here because extensions are never nested.
658659
}
659660

661+
/// Returns true if the conformance of \p nominal to \p proto is declared in
662+
/// module \p M.
663+
static bool conformanceDeclaredInModule(ModuleDecl *M,
664+
const NominalTypeDecl *nominal,
665+
ProtocolDecl *proto) {
666+
SmallVector<ProtocolConformance *, 4> conformances;
667+
nominal->lookupConformance(M, proto, conformances);
668+
return llvm::all_of(conformances,
669+
[M](const ProtocolConformance *conformance) -> bool {
670+
return M == conformance->getDeclContext()->getParentModule();
671+
});
672+
}
673+
660674
/// If there were any public protocols that need to be printed (i.e. they
661675
/// weren't conformed to explicitly or inherited by another printed protocol),
662676
/// do so now by printing a dummy extension on \p nominal to \p out.
663677
void
664678
printSynthesizedExtensionIfNeeded(raw_ostream &out,
665679
const PrintOptions &printOptions,
680+
ModuleDecl *M,
666681
const NominalTypeDecl *nominal) const {
667682
if (ExtraProtocols.empty())
668683
return;
@@ -688,10 +703,13 @@ class InheritedProtocolCollector {
688703
[&](ProtocolDecl *inherited) -> TypeWalker::Action {
689704
if (!handledProtocols.insert(inherited).second)
690705
return TypeWalker::Action::SkipChildren;
691-
if (isPublicOrUsableFromInline(inherited)) {
706+
707+
if (isPublicOrUsableFromInline(inherited) &&
708+
conformanceDeclaredInModule(M, nominal, inherited)) {
692709
protocolsToPrint.push_back(inherited);
693710
return TypeWalker::Action::SkipChildren;
694711
}
712+
695713
return TypeWalker::Action::Continue;
696714
});
697715
}
@@ -775,7 +793,7 @@ bool swift::emitParseableInterface(raw_ostream &out,
775793
for (const auto &nominalAndCollector : inheritedProtocolMap) {
776794
const NominalTypeDecl *nominal = nominalAndCollector.first;
777795
const InheritedProtocolCollector &collector = nominalAndCollector.second;
778-
collector.printSynthesizedExtensionIfNeeded(out, printOptions, nominal);
796+
collector.printSynthesizedExtensionIfNeeded(out, printOptions, M, nominal);
779797
needDummyProtocolDeclaration |=
780798
collector.printInaccessibleConformanceExtensionIfNeeded(out,
781799
printOptions,

trunk/test/ParseableInterface/conformances.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ extension MultiGeneric: PublicProto where U: PrivateProto {}
167167
// CHECK: public struct MultiGeneric<T, U, V> {
168168
// CHECK-END: extension conformances.MultiGeneric : PublicProto where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
169169

170+
170171
internal struct InternalImpl_BAD: PrivateSubProto {}
171172
internal struct InternalImplConstrained_BAD<T> {}
172173
extension InternalImplConstrained_BAD: PublicProto where T: PublicProto {}
@@ -182,5 +183,12 @@ extension WrapperForInternal.InternalImplConstrained_BAD: PublicProto where T: P
182183
extension WrapperForInternal.InternalImplConstrained2_BAD: PublicProto where T: PrivateProto {}
183184

184185

186+
internal protocol ExtraHashable: Hashable {}
187+
extension Bool: ExtraHashable {}
188+
189+
// NEGATIVE-NOT: extension {{(Swift.)?}}Bool{{.+}}Hashable
190+
// NEGATIVE-NOT: extension {{(Swift.)?}}Bool{{.+}}Equatable
191+
192+
185193
// CHECK-END: @usableFromInline
186194
// CHECK-END-NEXT: internal protocol _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}

0 commit comments

Comments
 (0)