Files
swift-mirror/test/Serialization/invertible_protocols_parse_stdlib.swift
Allan Shortlidge 95a50874be AST: Don't synthesize duplicates of invertible protocols in the stdlib.
A stdlib built from source serializes its synthesized invertible protocols,
but resolving a `Builtin` reference to one of them synthesized a second
declaration anyway. Types from a `-parse-stdlib` module that doesn't import
the stdlib then appeared noncopyable and non-`Deinitable` to clients that do.
Reuse the stdlib's declaration when it already has one.

Resolves rdar://189492926.
2026-10-09 13:15:17 -07:00

39 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// A stdlib built from source serializes the invertible protocols that were
// synthesized into it. A module built with -parse-stdlib that doesn't import
// the stdlib refers to those protocols in the Builtin module instead. Both
// references must resolve to the same protocol declarations in a client that
// imports both modules.
// RUN: %target-swift-frontend -emit-module -parse-stdlib -module-name Swift \
// RUN: -o %t/Swift.swiftmodule %t/Swift.swift
// RUN: %target-swift-frontend -emit-module -parse-stdlib -module-name Lib \
// RUN: -o %t/Lib.swiftmodule %t/Lib.swift
// RUN: %target-swift-frontend -typecheck -verify -parse-stdlib -I %t \
// RUN: %t/ClientImportingSwiftFirst.swift
// RUN: %target-swift-frontend -typecheck -verify -parse-stdlib -I %t \
// RUN: %t/ClientImportingLibFirst.swift
//--- Swift.swift
public struct Int {}
//--- Lib.swift
public struct S {}
//--- ClientImportingSwiftFirst.swift
import Swift
import Lib
func takeInt(_ x: Int) {}
func takeS(_ x: S) {} // Requires that S is Copyable.
//--- ClientImportingLibFirst.swift
import Lib
import Swift
func takeInt(_ x: Int) {}
func takeS(_ x: S) {} // Requires that S is Copyable.