-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix a few more callers of ProtocolConformanceRef::forAbstract() to pass in a subject type #80107
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
slavapestov
merged 6 commits into
swiftlang:main
from
slavapestov:for-abstract-conformance
Mar 19, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
efbeaea
AST: Always-on ASSERTs for ProtocolConformanceRef
slavapestov f7b0b72
Sema: Refactor TypeChecker::containsProtocol() a bit
slavapestov a00157e
IRGen: Refactor LocalTypeData a bit
slavapestov 2a41a32
SIL: Fix a call to ProtocolConformanceRef::forAbstract()
slavapestov 8bcd09a
SIL: Preliminary refactoring of SILWitnessTable::AssociatedConformanc…
slavapestov 9c657e4
Serialization: Fix a call to ProtocolConformanceRef::forAbstract()
slavapestov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1780,9 +1780,6 @@ class AccessorConformanceInfo : public ConformanceInfo { | |
auto associatedWitness = entry.getAssociatedConformanceWitness(); | ||
assert(associatedWitness.Requirement == requirement.getAssociation() | ||
&& "sil witness table does not match protocol"); | ||
assert(associatedWitness.Protocol == | ||
requirement.getAssociatedRequirement() | ||
&& "sil witness table does not match protocol"); | ||
auto piIndex = PI.getAssociatedConformanceIndex(requirement); | ||
assert((size_t)piIndex.getValue() == | ||
Table.size() - WitnessTableFirstRequirementOffset && | ||
|
@@ -1792,10 +1789,8 @@ class AccessorConformanceInfo : public ConformanceInfo { | |
if (IGM.Context.LangOpts.hasFeature(Feature::Embedded)) { | ||
// In Embedded Swift associated-conformance entries simply point to the witness table | ||
// of the associated conformance. | ||
ProtocolConformanceRef assocConf = | ||
SILWT->getConformance()->getAssociatedConformance(requirement.getAssociation(), | ||
requirement.getAssociatedRequirement()); | ||
llvm::Constant *witnessEntry = IGM.getAddrOfWitnessTable(assocConf.getConcrete()); | ||
ProtocolConformance *assocConf = associatedWitness.Witness.getConcrete(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is there a fix already happening for this? |
||
llvm::Constant *witnessEntry = IGM.getAddrOfWitnessTable(assocConf); | ||
auto &schema = IGM.getOptions().PointerAuth | ||
.ProtocolAssociatedTypeWitnessTableAccessFunctions; | ||
Table.addSignedPointer(witnessEntry, schema, requirement); | ||
|
@@ -2030,10 +2025,11 @@ void ResilientWitnessTableBuilder::collectResilientWitnesses( | |
|
||
ProtocolConformanceRef associatedConformance = | ||
ConformanceInContext.getAssociatedConformance(witness.Requirement, | ||
witness.Protocol); | ||
witness.Witness.getRequirement()); | ||
|
||
AssociatedConformance requirement(SILWT->getProtocol(), | ||
witness.Requirement, | ||
witness.Protocol); | ||
witness.Witness.getRequirement()); | ||
|
||
llvm::Constant *witnessEntry = | ||
getAssociatedConformanceWitness(requirement, associate, | ||
|
@@ -2353,7 +2349,7 @@ namespace { | |
|
||
AssociatedConformance requirement(SILWT->getProtocol(), | ||
witness.Requirement, | ||
witness.Protocol); | ||
witness.Witness.getRequirement()); | ||
auto assocConformanceDescriptor = | ||
IGM.getAddrOfLLVMVariableOrGOTEquivalent( | ||
LinkEntity::forAssociatedConformanceDescriptor(requirement)); | ||
|
@@ -3402,8 +3398,7 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF, | |
} | ||
|
||
case Component::Kind::OutOfLineBaseProtocol: { | ||
auto conformance = sourceKey.Kind.getProtocolConformance(); | ||
auto protocol = conformance.getRequirement(); | ||
auto protocol = sourceKey.Kind.getConformedProtocol(); | ||
auto &pi = IGF.IGM.getProtocolInfo(protocol, | ||
ProtocolInfoKind::RequirementSignature); | ||
|
||
|
@@ -3413,9 +3408,10 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF, | |
|
||
sourceKey.Kind = | ||
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol); | ||
if (conformance.isConcrete()) { | ||
if (sourceKey.Kind.isConcreteProtocolConformance()) { | ||
auto inheritedConformance = | ||
conformance.getConcrete()->getInheritedConformance(inheritedProtocol); | ||
sourceKey.Kind.getConcreteProtocolConformance() | ||
->getInheritedConformance(inheritedProtocol); | ||
if (inheritedConformance) { | ||
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable( | ||
inheritedConformance); | ||
|
@@ -3438,8 +3434,8 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF, | |
|
||
case Component::Kind::AssociatedConformance: { | ||
auto sourceType = sourceKey.Type; | ||
auto sourceConformance = sourceKey.Kind.getProtocolConformance(); | ||
auto sourceProtocol = sourceConformance.getRequirement(); | ||
auto sourceConformance = sourceKey.Kind.getProtocolConformance(sourceType); | ||
auto sourceProtocol = sourceKey.Kind.getConformedProtocol(); | ||
auto &pi = IGF.IGM.getProtocolInfo(sourceProtocol, | ||
ProtocolInfoKind::RequirementSignature); | ||
|
||
|
@@ -3473,7 +3469,8 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF, | |
// In Embedded Swift associated-conformance entries simply point to the witness table | ||
// of the associated conformance. | ||
llvm::Value *sourceWTable = source.getMetadata(); | ||
llvm::Value *associatedWTable = emitAssociatedConformanceValue(IGF, sourceWTable, associatedConformanceRef); | ||
llvm::Value *associatedWTable = emitAssociatedConformanceValue( | ||
IGF, sourceWTable, associatedConformanceRef); | ||
return MetadataResponse::forComplete(associatedWTable); | ||
} | ||
|
||
|
@@ -3562,13 +3559,13 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF, | |
} | ||
|
||
case Component::Kind::ConditionalConformance: { | ||
auto sourceConformance = sourceKey.Kind.getProtocolConformance(); | ||
auto sourceConformance = sourceKey.Kind.getConcreteProtocolConformance(); | ||
|
||
auto reqtIndex = component.getPrimaryIndex(); | ||
|
||
ProtocolDecl *conformingProto; | ||
auto found = SILWitnessTable::enumerateWitnessTableConditionalConformances( | ||
sourceConformance.getConcrete(), | ||
sourceConformance, | ||
[&](unsigned index, CanType type, ProtocolDecl *proto) { | ||
if (reqtIndex == index) { | ||
conformingProto = proto; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you name this
var `protocol`: ProtocolDecl
. We try to avoid abbreviations in the swift APIs as good as possible.Note that the backticks are not needed when using this property, e.g.
p = c.protocol