File tree Expand file tree Collapse file tree 7 files changed +34
-11
lines changed
validation-test/Serialization Expand file tree Collapse file tree 7 files changed +34
-11
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,8 @@ enum class ConformanceLookupKind : unsigned {
149
149
All,
150
150
// / Only the explicit conformance.
151
151
OnlyExplicit,
152
+ // / All conformances except for inherited ones.
153
+ NonInherited,
152
154
};
153
155
154
156
// / Describes a diagnostic for a conflict between two protocol
Original file line number Diff line number Diff line change @@ -989,10 +989,30 @@ void ConformanceLookupTable::lookupConformances(
989
989
return true ;
990
990
991
991
// If we are to filter out this result, do so now.
992
- if (lookupKind == ConformanceLookupKind::OnlyExplicit &&
993
- entry->getKind () != ConformanceEntryKind::Explicit &&
994
- entry->getKind () != ConformanceEntryKind::Synthesized)
995
- return false ;
992
+ switch (lookupKind) {
993
+ case ConformanceLookupKind::OnlyExplicit:
994
+ switch (entry->getKind ()) {
995
+ case ConformanceEntryKind::Explicit:
996
+ case ConformanceEntryKind::Synthesized:
997
+ break ;
998
+ case ConformanceEntryKind::Implied:
999
+ case ConformanceEntryKind::Inherited:
1000
+ return false ;
1001
+ }
1002
+ break ;
1003
+ case ConformanceLookupKind::NonInherited:
1004
+ switch (entry->getKind ()) {
1005
+ case ConformanceEntryKind::Explicit:
1006
+ case ConformanceEntryKind::Synthesized:
1007
+ case ConformanceEntryKind::Implied:
1008
+ break ;
1009
+ case ConformanceEntryKind::Inherited:
1010
+ return false ;
1011
+ }
1012
+ break ;
1013
+ case ConformanceLookupKind::All:
1014
+ break ;
1015
+ }
996
1016
997
1017
// Record the protocol.
998
1018
if (protocols)
Original file line number Diff line number Diff line change @@ -1436,7 +1436,7 @@ void SILGenModule::emitExternalDefinition(Decl *d) {
1436
1436
case DeclKind::Class: {
1437
1437
// Emit witness tables.
1438
1438
auto nom = cast<NominalTypeDecl>(d);
1439
- for (auto c : nom->getLocalConformances (ConformanceLookupKind::All ,
1439
+ for (auto c : nom->getLocalConformances (ConformanceLookupKind::NonInherited ,
1440
1440
nullptr )) {
1441
1441
auto *proto = c->getProtocol ();
1442
1442
if (Lowering::TypeConverter::protocolRequiresWitnessTable (proto) &&
Original file line number Diff line number Diff line change @@ -976,7 +976,7 @@ class SILGenType : public TypeMemberVisitor<SILGenType> {
976
976
// Emit witness tables for conformances of concrete types. Protocol types
977
977
// are existential and do not have witness tables.
978
978
for (auto *conformance : theType->getLocalConformances (
979
- ConformanceLookupKind::All , nullptr )) {
979
+ ConformanceLookupKind::NonInherited , nullptr )) {
980
980
if (conformance->isComplete ()) {
981
981
if (auto *normal = dyn_cast<NormalProtocolConformance>(conformance))
982
982
SGM.getWitnessTable (normal);
Original file line number Diff line number Diff line change @@ -3217,7 +3217,7 @@ void Serializer::writeDecl(const Decl *D) {
3217
3217
auto contextID = addDeclContextRef (theClass->getDeclContext ());
3218
3218
3219
3219
auto conformances = theClass->getLocalConformances (
3220
- ConformanceLookupKind::All , nullptr );
3220
+ ConformanceLookupKind::NonInherited , nullptr );
3221
3221
3222
3222
SmallVector<TypeID, 4 > inheritedTypes;
3223
3223
for (auto inherited : theClass->getInherited ()) {
Original file line number Diff line number Diff line change @@ -114,7 +114,8 @@ void TBDGenVisitor::addBaseConformanceDescriptor(
114
114
}
115
115
116
116
void TBDGenVisitor::addConformances (DeclContext *DC) {
117
- for (auto conformance : DC->getLocalConformances ()) {
117
+ for (auto conformance : DC->getLocalConformances (
118
+ ConformanceLookupKind::NonInherited)) {
118
119
auto protocol = conformance->getProtocol ();
119
120
auto needsWTable =
120
121
Lowering::TypeConverter::protocolRequiresWitnessTable (protocol);
Original file line number Diff line number Diff line change 1
1
// RUN: %empty-directory(%t)
2
- // RUN: %target-build-swift -emit-sil -emit-module-path %t/SwiftLib.swiftmodule -I %S/Inputs/conformance-removed/ %S/Inputs/conformance-removed/SwiftLib.swift -Xcc -DUSE_PROTO
3
- // RUN: not --crash %target-build-swift -typecheck -I %t -I %S/Inputs/custom-modules/ %s 2>&1 | %FileCheck %s
2
+ // RUN: %target-build-swift -emit-module -emit-module-path %t/SwiftLib.swiftmodule -I %S/Inputs/conformance-removed/ %S/Inputs/conformance-removed/SwiftLib.swift -Xcc -DUSE_PROTO
3
+ // RUN: not grep SomeProto %t/SwiftLib.swiftmodule
4
+ // RUN: %target-build-swift -typecheck -I %t -I %S/Inputs/custom-modules/ %s
4
5
5
6
// REQUIRES: objc_interop
6
7
7
8
import SwiftLib
8
9
class Rdar28282310 : Sub { }
9
- // CHECK: If you're seeing a crash here, check that your SDK and dependencies are at least as new as the versions used to build 'SwiftLib'
You can’t perform that action at this time.
0 commit comments