@@ -3753,7 +3753,7 @@ internal struct ValidatingInstantiateKeyPathBuffer: KeyPathPatternVisitor {
3753
3753
offset: offset)
3754
3754
checkSizeConsistency ( )
3755
3755
structOffset = instantiateVisitor. structOffset
3756
- isPureStruct = instantiateVisitor. isPureStruct
3756
+ isPureStruct. append ( contentsOf : instantiateVisitor. isPureStruct)
3757
3757
}
3758
3758
mutating func visitComputedComponent( mutating: Bool ,
3759
3759
idKind: KeyPathComputedIDKind ,
@@ -3782,32 +3782,41 @@ internal struct ValidatingInstantiateKeyPathBuffer: KeyPathPatternVisitor {
3782
3782
setter: setter,
3783
3783
arguments: arguments,
3784
3784
externalArgs: externalArgs)
3785
+ // Note: For this function and the ones below, modification of structOffset
3786
+ // is omitted since these types of KeyPaths won't have a pureStruct
3787
+ // offset anyway.
3788
+ isPureStruct. append ( contentsOf: instantiateVisitor. isPureStruct)
3785
3789
checkSizeConsistency ( )
3786
3790
}
3787
3791
mutating func visitOptionalChainComponent( ) {
3788
3792
sizeVisitor. visitOptionalChainComponent ( )
3789
3793
instantiateVisitor. visitOptionalChainComponent ( )
3794
+ isPureStruct. append ( contentsOf: instantiateVisitor. isPureStruct)
3790
3795
checkSizeConsistency ( )
3791
3796
}
3792
3797
mutating func visitOptionalWrapComponent( ) {
3793
3798
sizeVisitor. visitOptionalWrapComponent ( )
3794
3799
instantiateVisitor. visitOptionalWrapComponent ( )
3800
+ isPureStruct. append ( contentsOf: instantiateVisitor. isPureStruct)
3795
3801
checkSizeConsistency ( )
3796
3802
}
3797
3803
mutating func visitOptionalForceComponent( ) {
3798
3804
sizeVisitor. visitOptionalForceComponent ( )
3799
3805
instantiateVisitor. visitOptionalForceComponent ( )
3806
+ isPureStruct. append ( contentsOf: instantiateVisitor. isPureStruct)
3800
3807
checkSizeConsistency ( )
3801
3808
}
3802
3809
mutating func visitIntermediateComponentType( metadataRef: MetadataReference ) {
3803
3810
sizeVisitor. visitIntermediateComponentType ( metadataRef: metadataRef)
3804
3811
instantiateVisitor. visitIntermediateComponentType ( metadataRef: metadataRef)
3812
+ isPureStruct. append ( contentsOf: instantiateVisitor. isPureStruct)
3805
3813
checkSizeConsistency ( )
3806
3814
}
3807
3815
3808
3816
mutating func finish( ) {
3809
3817
sizeVisitor. finish ( )
3810
3818
instantiateVisitor. finish ( )
3819
+ isPureStruct. append ( contentsOf: instantiateVisitor. isPureStruct)
3811
3820
checkSizeConsistency ( )
3812
3821
}
3813
3822
@@ -3885,14 +3894,6 @@ internal func _instantiateKeyPathBuffer(
3885
3894
isPureStruct = isPureStruct && value
3886
3895
}
3887
3896
3888
- // Disable the optimization in the general case of 0 components.
3889
- // Note that a KeyPath such as \SomeStruct.self would still technically
3890
- // have a valid offset of 0.
3891
- // TODO: Add the logic to distinguish pure struct
3892
- // 0-component KeyPaths (tuples too?) from others.
3893
- if walker. isPureStruct. count == 0 {
3894
- isPureStruct = false
3895
- }
3896
3897
if isPureStruct {
3897
3898
offset = walker. structOffset
3898
3899
}
0 commit comments