Skip to content

Commit b872052

Browse files
authored
Merge pull request #29535 from slavapestov/inherited-init-sugar-fix
Sema: Fix module interface printing of inherited generic initializers
2 parents 2c39aa1 + 3c86061 commit b872052

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,8 @@ configureGenericDesignatedInitOverride(ASTContext &ctx,
411411
auto *gp = cast<GenericTypeParamType>(type);
412412
if (gp->getDepth() < superclassDepth)
413413
return Type(gp).subst(subMap);
414-
return CanGenericTypeParamType::get(
415-
gp->getDepth() - superclassDepth + depth,
416-
gp->getIndex(),
417-
ctx);
414+
return genericParams->getParams()[gp->getIndex()]
415+
->getDeclaredInterfaceType();
418416
};
419417

420418
auto lookupConformanceFn =

test/ModuleInterface/inherited-generic-parameters.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
public class Base<In, Out> {
1616
// CHECK-NEXT: public init(x: @escaping (In) -> Out)
1717
public init(x: @escaping (In) -> Out) {}
18+
19+
// CHECK-NEXT: public init<A>(_: A, _: A)
20+
public init<A>(_: A, _: A) {}
21+
1822
// CHECK: }
1923
}
2024

2125
// CHECK: public class Derived<T> : {{(main.)?}}Base<T, T> {
2226
public class Derived<T> : Base<T, T> {
2327
// CHECK-NEXT: {{(@objc )?}}deinit
2428
// CHECK-NEXT: override public init(x: @escaping (T) -> T)
29+
// CHECK-NEXT: override public init<A>(_ argument: A, _ argument: A)
2530
// CHECK-NEXT: }
2631
}
2732

0 commit comments

Comments
 (0)