Skip to content

Commit 8563516

Browse files
committed
Revert "SILGen: Fix inout re-abstraction for default witnesses"
This reverts commit 0029448.
1 parent 357d325 commit 8563516

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

lib/SILGen/SILGenDecl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,10 +1814,13 @@ SILGenModule::emitProtocolWitness(ProtocolConformance *conformance,
18141814
if (conformance) {
18151815
selfType = conformance->getType();
18161816

1817-
// For default implementations, Self is the protocol archetype.
1817+
// For default implementations, Self is the contextual type of the
1818+
// extension (or, once we add default implementations inside protocols,
1819+
// the protocol's Self type).
18181820
} else {
1819-
auto *proto = cast<ProtocolDecl>(requirement.getDecl()->getDeclContext());
1820-
selfType = proto->getProtocolSelf()->getArchetype();
1821+
DeclContext *dc = witness.getDecl()->getDeclContext();
1822+
assert(dc->getAsProtocolOrProtocolExtensionContext());
1823+
selfType = dc->getDeclaredTypeOfContext();
18211824
}
18221825
}
18231826

test/SILGen/protocol_resilience.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ public protocol ResilientStorage {
9999
var mutableGenericPropertyWithDefault: T { get set }
100100

101101
subscript(x: T) -> T { get set }
102-
103-
var mutatingGetterWithNonMutatingDefault: Int { mutating get set }
104102
}
105103

106104
extension ResilientStorage {
@@ -153,18 +151,6 @@ extension ResilientStorage {
153151
set { }
154152
}
155153

156-
// CHECK-LABEL: sil [transparent] [thunk] @_TFP19protocol_resilience16ResilientStorageg36mutatingGetterWithNonMutatingDefaultSi
157-
// CHECK-LABEL: sil @_TFE19protocol_resiliencePS_16ResilientStorageg36mutatingGetterWithNonMutatingDefaultSi
158-
// CHECK-LABEL: sil [transparent] [thunk] @_TFP19protocol_resilience16ResilientStorages36mutatingGetterWithNonMutatingDefaultSi
159-
// CHECK-LABEL: sil @_TFE19protocol_resiliencePS_16ResilientStorages36mutatingGetterWithNonMutatingDefaultSi
160-
// CHECK-LABEL: sil [transparent] [thunk] @_TFP19protocol_resilience16ResilientStoragem36mutatingGetterWithNonMutatingDefaultSi
161-
// CHECK-LABEL: sil [transparent] @_TFFP19protocol_resilience16ResilientStoragem36mutatingGetterWithNonMutatingDefaultSiU_T_
162-
public var mutatingGetterWithNonMutatingDefault: Int {
163-
get {
164-
return 0
165-
}
166-
set { }
167-
}
168154
}
169155

170156

@@ -262,9 +248,6 @@ protocol InternalProtocol {
262248
// CHECK-NEXT: method #ResilientStorage.subscript!getter.1: @_TFP19protocol_resilience16ResilientStorageg9subscriptFwx1TwxS1_
263249
// CHECK-NEXT: method #ResilientStorage.subscript!setter.1: @_TFP19protocol_resilience16ResilientStorages9subscriptFwx1TwxS1_
264250
// CHECK-NEXT: method #ResilientStorage.subscript!materializeForSet.1: @_TFP19protocol_resilience16ResilientStoragem9subscriptFwx1TwxS1_
265-
// CHECK-NEXT: method #ResilientStorage.mutatingGetterWithNonMutatingDefault!getter.1: @_TFP19protocol_resilience16ResilientStorageg36mutatingGetterWithNonMutatingDefaultSi
266-
// CHECK-NEXT: method #ResilientStorage.mutatingGetterWithNonMutatingDefault!setter.1: @_TFP19protocol_resilience16ResilientStorages36mutatingGetterWithNonMutatingDefaultSi
267-
// CHECK-NEXT: method #ResilientStorage.mutatingGetterWithNonMutatingDefault!materializeForSet.1: @_TFP19protocol_resilience16ResilientStoragem36mutatingGetterWithNonMutatingDefaultSi
268251
// CHECK-NEXT: }
269252

270253
// CHECK-LABEL: sil_default_witness_table ResilientOperators {

0 commit comments

Comments
 (0)