Files
swift-mirror/test/ModuleInterface/specialized-extension.swift
Robert Widmann 25ab410896 Implement (Sugared) Bound Generic Extensions
A scoped-down version of #39307. Implement extension of bound generic types. The important bit here is in TypeCheckGeneric where we now use the underlying type of a typealias and its associated nominal type decl when we're generating substitutions for the extended type.

Put this behind a new experimental flag

-enable-experimental-bound-generic-extensions

Resolves SR-4875
Resolves rdar://17434633
2022-02-02 17:05:23 -08:00

41 lines
1.5 KiB
Swift

// RUN: %target-swift-frontend -module-name Test -typecheck -emit-module-interface-path - -enable-experimental-bound-generic-extensions %s | %FileCheck %s
public struct Tree<T> {
public struct Branch<B> {
public struct Nest<N> {
public struct Egg {}
}
}
}
// CHECK: extension Test.Tree.Branch.Nest.Egg {
// CHECK: public static func tweet()
// CHECK: }
extension Tree.Branch.Nest.Egg { public static func tweet() {} }
// CHECK: extension Test.Tree.Branch.Nest.Egg where T == Swift.Int {
// CHECK: public static func twoot()
// CHECK: }
extension Tree<Int>.Branch.Nest.Egg { public static func twoot() {} }
// CHECK: extension Test.Tree.Branch.Nest.Egg where T == Swift.Int, B == Swift.String {
// CHECK: public static func twote()
// CHECK: }
extension Tree<Int>.Branch<String>.Nest.Egg { public static func twote() {} }
// CHECK: extension Test.Tree.Branch.Nest.Egg where T == Swift.Int, B == Swift.String, N == Swift.Void {
// CHECK: public static func twite()
// CHECK: }
extension Tree<Int>.Branch<String>.Nest<Void>.Egg { public static func twite() {} }
// CHECK: extension Swift.Array where Element == Swift.String {
// CHECK: public func rejoinder() -> Swift.String
// CHECK: }
extension [String] { public func rejoinder() -> String { return self.joined() } }
// CHECK: public typealias StringDict<T> = [Swift.String : T]
public typealias StringDict<T> = [String: T]
// CHECK: extension Swift.Dictionary where Key == Swift.String, Value == Swift.Int
extension StringDict<Int> { public static func mark() {} }