Skip to content

Commit c02ffaf

Browse files
authored
Merge pull request #12286 from DougGregor/subst-inout-param-type
[Type checker] Drop parameter 'inout' types in a few more places.
2 parents dab6971 + b4acc38 commit c02ffaf

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ swift::createDesignatedInitOverride(TypeChecker &tc,
20752075
classDecl->getGenericEnvironment());
20762076

20772077
for (auto *decl : *bodyParams) {
2078-
auto paramTy = decl->getInterfaceType();
2078+
auto paramTy = decl->getInterfaceType()->getInOutObjectType();
20792079

20802080
// Apply the superclass substitutions to produce a contextual
20812081
// type in terms of the derived class archetypes.
@@ -2089,7 +2089,9 @@ swift::createDesignatedInitOverride(TypeChecker &tc,
20892089
} else {
20902090
for (auto *decl : *bodyParams) {
20912091
if (!decl->hasType())
2092-
decl->setType(classDecl->mapTypeIntoContext(decl->getInterfaceType()));
2092+
decl->setType(
2093+
classDecl->mapTypeIntoContext(
2094+
decl->getInterfaceType()->getInOutObjectType()));
20932095
}
20942096
}
20952097

test/decl/inherit/initializer.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public class Node {
168168
}
169169
}
170170

171-
final class SubNode : Node {
171+
class SubNode : Node {
172172
var a: Int
173173

174174
required init(node: Node) {
@@ -181,3 +181,28 @@ final class SubNode : Node {
181181
super.init(data: &data)
182182
}
183183
}
184+
185+
class GenericSubNode<T> : SubNode {
186+
required init(node: Node) {
187+
super.init(node: node)
188+
}
189+
190+
init(data: inout Data, value: T) {
191+
super.init(data: &data, additionalParam: 1)
192+
}
193+
}
194+
195+
protocol HasValue {
196+
associatedtype Value
197+
func getValue() -> Value
198+
}
199+
200+
class GenericWrapperNode<T : HasValue> : GenericSubNode<T.Value> {
201+
required init(node: Node) {
202+
super.init(node: node)
203+
}
204+
205+
init(data: inout Data, otherValue: T) {
206+
super.init(data: &data, value: otherValue.getValue())
207+
}
208+
}

0 commit comments

Comments
 (0)