Files
swift-mirror/test/Availability/spi-available-swift-module.swift
Alexis Laferrière 2d339c1260 Sema: Custom diagnostic for var decls referencing a restricted type
Replace the `here` part of the generic exportability diagnostic for
variables with: `in a property declaration marked public or in a
'@frozen' or '@usableFromInline' context`.

The full diagnostic now looks like:
```
error: cannot use struct 'ImportedType' in a property declaration marked
public or in a '@frozen' or '@usableFromInline' context;
'HiddenDependency' has been imported as implementation-only
```

This should be improved further to support implicitly exported memory
layouts in non-library-evolution and embedded.
2025-10-21 11:30:52 -07:00

27 lines
879 B
Swift

// REQUIRES: OS=macosx
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -parse-as-library %t/Foo.swift -emit-module -library-level api -emit-module-path %t/Foo.swiftmodule -module-name Foo
// RUN: %target-swift-frontend-typecheck -parse-as-library %t/Client.swift -verify -verify-ignore-unrelated -library-level api -I %t
//--- Foo.swift
@_spi_available(macOS 10.10, *)
@available(iOS 8.0, *)
public class MacOSSPIClass {}
@_spi_available(iOS 8.0, *)
@available(macOS 10.10, *)
public class iOSSPIClass {}
//--- Client.swift
import Foo
@available(macOS 10.10, iOS 8.0, *)
public struct Foo {
public var macos: MacOSSPIClass // expected-error {{cannot use class 'MacOSSPIClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from 'Foo'}}
public var ios: iOSSPIClass
}