Files
swift-mirror/test/ModuleInterface/reparenting.swift
Kavon Farvardin 58ad64d3f4 Reparenting: fix interface emission
The `@reparented` was missing and a typealias
was being synthesized unexpectedly, creating
an issue when typechecking the interface later.

There's no fundamental reason why typealiases
cannot be supported to say the same thing as
the same-type requirement, but I think the
same-type requirement is always needed to be
written on the extension, one way or another.

For now I've chosen to only go with an
explicitly-written same-type requirement.
2026-02-06 13:23:22 -08:00

30 lines
997 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -module-name Library -enable-experimental-feature Reparenting
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -module-name Library
// RUN: %FileCheck %s --check-prefixes=CHECK < %t/Library.swiftinterface
// REQUIRES: swift_feature_Reparenting
// CHECK-LABEL: @reparentable public protocol Circle {
@reparentable
public protocol Circle {
associatedtype Color
func fill() -> Color
}
// CHECK-LABEL: public protocol Ball : Library.Circle {
// CHECK: associatedtype Color = Swift.Int
public protocol Ball: Circle {
associatedtype Color = Int
func roll()
}
// CHECK-LABEL: extension Library.Ball : @reparented Library.Circle where Self.Color == Swift.Int {
// CHECK: public func fill() -> Self.Color
// CHECK-NOT: typealias
extension Ball: @reparented Circle where Color == Int {
public func fill() -> Color { return 0xFFFD74 }
}