Files
swift-mirror/test/SPI/accidental-reexport.swift
Alexis Laferrière bd4e5e7615 Sema: Add test guarding against accidental SPI reexport via clang modules
Exported imports are common between clang modules. Make sure we test
against accidently reexporting Swift SPIs through these exported
imports.
2023-12-20 13:15:59 -08:00

52 lines
1.0 KiB
Swift

/// Guard that we don't reexport the SPIs accidentally through the common
/// reexported imports between clang modules.
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -emit-module %t/Overlayed.swift -I %t -o %t
// RUN: %target-swift-frontend -typecheck -verify %t/Client.swift -I %t
// RUN: %target-swift-frontend -typecheck -verify %t/LowerClient.swift -I %t
//--- module.modulemap
module Overlayed {
header "Overlayed.h"
}
module Middle {
header "Middle.h"
export *
}
module LowerMiddle {
header "LowerMiddle.h"
export *
}
//--- Overlayed.h
//--- Overlayed.swift
@_exported import Overlayed
public func funcPublic() {}
@_spi(X)
public func funcSPI() {}
//--- Middle.h
#include <Overlayed.h>
//--- LowerMiddle.h
#include <Middle.h>
//--- Client.swift
@_spi(X) import Middle
funcPublic()
funcSPI() // expected-error {{cannot find 'funcSPI' in scope}}
//--- LowerClient.swift
@_spi(X) import LowerMiddle
funcPublic()
funcSPI() // expected-error {{cannot find 'funcSPI' in scope}}