Files
swift-mirror/test/ModuleInterface/inherited-generic-parameters.swift
Slava Pestov ce550f2464 AST: Try harder to preserve type sugar in AbstractGenericSignatureRequest
AbstractGenericSignatureRequest tries to minimize the number of GSBs that we
spin up by only creating a GSB if the generic parameter and requirement types
are canonical. If they're not canonical, it first canonicalizes them, then
kicks off a request to compute the canonical signature, and finally, re-applies
type sugar.

We would do this by building a mapping for re-sugaring generic parameters,
however this mapping was only populated for the newly-added generic parameters.

If some of the newly-added generic requirements mention the base signature's
generic parameters, they would remain canonicalized.

Fixes <rdar://problem/67579220>.
2020-08-24 19:16:36 -04:00

36 lines
1.4 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -typecheck %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
// RUN: %FileCheck %s < %t/main.swiftinterface
// RUN: %target-swift-frontend -emit-module -module-name main -primary-file %s -emit-module-path %t/main~partial.swiftmodule -enable-library-evolution
// RUN: %target-swift-frontend -merge-modules %t/main~partial.swiftmodule -emit-module-path %t/main.swiftmodule -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
// RUN: %FileCheck %s < %t/main.swiftinterface
// This test makes sure that we substitute uses of the superclass's generic
// parameters when we inherit initializers.
// CHECK: public class Base<In, Out> {
public class Base<In, Out> {
// CHECK-NEXT: public init(x: @escaping (In) -> Out)
public init(x: @escaping (In) -> Out) {}
// CHECK-NEXT: public init<A>(_: A, _: A)
public init<A>(_: A, _: A) {}
// CHECK-NEXT: public init<C>(_: C) where C : main.Base<In, Out>
public init<C>(_: C) where C : Base<In, Out> {}
// CHECK: }
}
// CHECK: public class Derived<T> : {{(main.)?}}Base<T, T> {
public class Derived<T> : Base<T, T> {
// CHECK-NEXT: {{(@objc )?}}deinit
// CHECK-NEXT: override public init(x: @escaping (T) -> T)
// CHECK-NEXT: override public init<A>(_ argument: A, _ argument: A)
// CHECK-NEXT: override public init<C>(_ argument: C) where C : main.Base<T, T>
// CHECK-NEXT: }
}