|
| 1 | +/// Test duplicate and conflicting imports from the same file. |
| 2 | + |
| 3 | +// RUN: %empty-directory(%t) |
| 4 | +// RUN: split-file %s %t |
| 5 | + |
| 6 | +/// Generate dependencies. |
| 7 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift \ |
| 8 | +// RUN: -module-name Lib -emit-module-path %t/Lib.swiftmodule \ |
| 9 | +// RUN: -swift-version 5 -enable-library-evolution |
| 10 | + |
| 11 | +/// Build clients. |
| 12 | +// RUN: %target-swift-frontend -typecheck %t/SPIOnly_Default.swift -I %t -verify \ |
| 13 | +// RUN: -experimental-spi-only-imports -verify |
| 14 | +// RUN: %target-swift-frontend -typecheck %t/Default_SPIOnly.swift -I %t -verify \ |
| 15 | +// RUN: -experimental-spi-only-imports -verify |
| 16 | +// RUN: %target-swift-frontend -typecheck %t/SPIOnly_Exported.swift -I %t -verify \ |
| 17 | +// RUN: -experimental-spi-only-imports -verify |
| 18 | +// RUN: %target-swift-frontend -typecheck %t/Exported_SPIOnly.swift -I %t -verify \ |
| 19 | +// RUN: -experimental-spi-only-imports -verify |
| 20 | +// RUN: %target-swift-frontend -typecheck %t/SPIOnly_IOI.swift -I %t -verify \ |
| 21 | +// RUN: -experimental-spi-only-imports -verify |
| 22 | +// RUN: %target-swift-frontend -typecheck %t/SPIOnly_IOI_Exported_Default.swift -I %t -verify \ |
| 23 | +// RUN: -experimental-spi-only-imports -verify |
| 24 | +// RUN: %target-swift-frontend -typecheck -primary-file %t/SPIOnly_Default_FileA.swift \ |
| 25 | +// RUN: %t/SPIOnly_Default_FileB.swift -I %t -verify \ |
| 26 | +// RUN: -experimental-spi-only-imports -verify |
| 27 | +// RUN: %target-swift-frontend -typecheck -primary-file %t/IOI_Default_FileA.swift \ |
| 28 | +// RUN: %t/IOI_Default_FileB.swift -I %t -verify \ |
| 29 | +// RUN: -experimental-spi-only-imports -verify |
| 30 | + |
| 31 | +//--- Lib.swift |
| 32 | +// Empty source file for import. |
| 33 | + |
| 34 | +//--- SPIOnly_Default.swift |
| 35 | +@_spiOnly import Lib // expected-note {{imported for SPI only here}} |
| 36 | +import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 37 | + |
| 38 | +//--- Default_SPIOnly.swift |
| 39 | +import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 40 | +@_spiOnly import Lib // expected-note {{imported for SPI only here}} |
| 41 | + |
| 42 | +//--- SPIOnly_Exported.swift |
| 43 | +@_spiOnly import Lib // expected-note {{imported for SPI only here}} |
| 44 | +@_exported import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 45 | + |
| 46 | +//--- Exported_SPIOnly.swift |
| 47 | +@_exported import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 48 | +@_spiOnly import Lib // expected-note {{imported for SPI only here}} |
| 49 | + |
| 50 | +//--- SPIOnly_IOI.swift |
| 51 | +@_spiOnly import Lib // expected-note {{imported for SPI only here}} |
| 52 | +// expected-warning @-1 {{'Lib' inconsistently imported as implementation-only}} |
| 53 | +@_implementationOnly import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 54 | +// expected-note @-1 {{imported as implementation-only here}} |
| 55 | + |
| 56 | +/// Many confliciting imports lead to many diagnostics. |
| 57 | +//--- SPIOnly_IOI_Exported_Default.swift |
| 58 | +@_spiOnly import Lib // expected-note 3 {{imported for SPI only here}} |
| 59 | +// expected-warning @-1 {{'Lib' inconsistently imported as implementation-only}} |
| 60 | +@_implementationOnly import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 61 | +// expected-note @-1 3 {{imported as implementation-only here}} |
| 62 | +@_exported import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 63 | +// expected-warning @-1 {{'Lib' inconsistently imported as implementation-only}} |
| 64 | +import Lib // expected-error {{'Lib' inconsistently imported for SPI only}} |
| 65 | +// expected-warning @-1 {{'Lib' inconsistently imported as implementation-only}} |
| 66 | + |
| 67 | +/// Different SPI only imports in different files of the same module are accepted. |
| 68 | +//--- SPIOnly_Default_FileA.swift |
| 69 | +@_spiOnly import Lib |
| 70 | + |
| 71 | +//--- SPIOnly_Default_FileB.swift |
| 72 | +import Lib |
| 73 | + |
| 74 | +/// Different IOI in different files of the same module are still rejected. |
| 75 | +//--- IOI_Default_FileA.swift |
| 76 | +@_implementationOnly import Lib // expected-note {{imported as implementation-only here}} |
| 77 | + |
| 78 | +//--- IOI_Default_FileB.swift |
| 79 | +import Lib // expected-warning {{'Lib' inconsistently imported as implementation-only}} |
0 commit comments