|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | + |
| 3 | +// RUN: %target-swift-frontend -emit-module -o %t/NormalLibrary.swiftmodule \ |
| 4 | +// RUN: %S/Inputs/implementation-only-import-in-decls-public-helper.swift \ |
| 5 | +// RUN: -enable-library-evolution -swift-version 5 |
| 6 | + |
| 7 | +// RUN: %target-swift-frontend -emit-module -o %t/BADLibrary.swiftmodule \ |
| 8 | +// RUN: %S/Inputs/implementation-only-import-in-decls-helper.swift -I %t \ |
| 9 | +// RUN: -enable-library-evolution -swift-version 5 |
| 10 | + |
| 11 | +// RUN: %target-typecheck-verify-swift -I %t \ |
| 12 | +// RUN: -swift-version 5 -package-name pkg -enable-library-evolution |
| 13 | +// RUN: %target-typecheck-verify-swift -I %t \ |
| 14 | +// RUN: -swift-version 5 -package-name pkg |
| 15 | + |
| 16 | +internal import BADLibrary // expected-note 9 {{protocol 'BadProto' imported as 'internal' from 'BADLibrary' here}} |
| 17 | +// expected-note @-1 2 {{struct 'IntLike' imported as 'internal' from 'BADLibrary' here}} |
| 18 | +// expected-note @-2 2 {{class 'BadClass' imported as 'internal' from 'BADLibrary' here}} |
| 19 | + |
| 20 | +public protocol LocalProto {} |
| 21 | + |
| 22 | +public struct TestConformance: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 23 | +public struct TestConformanceComposition: LocalProto & BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 24 | + |
| 25 | +@usableFromInline struct TestConformanceUFI: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 26 | + |
| 27 | +public class TestConformanceClass: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 28 | +public enum TestConformanceEnum: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 29 | + |
| 30 | +public struct TestExtensionStruct {} |
| 31 | +extension TestExtensionStruct: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 32 | + |
| 33 | +package struct TestConformancePackage: BadProto {} // FIXME-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 34 | +package struct TestConformanceCompositionPackage: LocalProto & BadProto {} // FIXME-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 35 | + |
| 36 | +@usableFromInline struct TestConformanceUFIPackage: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 37 | + |
| 38 | +package class TestConformanceClassPackage: BadProto {} // FIXME-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 39 | +package enum TestConformanceEnumPackage: BADLibrary.BadProto {} // FIXME-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 40 | + |
| 41 | +package struct TestExtensionStructPackage {} |
| 42 | +extension TestExtensionStructPackage: BadProto {} // FIXME-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; 'BADLibrary' was not imported publicly}} |
| 43 | + |
| 44 | +/// Other inheritance types are covered by the classic access-level check. |
| 45 | + |
| 46 | +public class TestSubclass: BadClass { // expected-error {{class cannot be declared public because its superclass is internal}} |
| 47 | +// expected-note @-1 {{class 'BadClass' is imported by this file as 'internal' from 'BADLibrary'}} |
| 48 | +} |
| 49 | + |
| 50 | +public enum TestRawType: IntLike { // expected-error {{enum cannot be declared public because its raw type uses an internal type}} |
| 51 | +// expected-note @-1 {{struct 'IntLike' is imported by this file as 'internal' from 'BADLibrary'}} |
| 52 | + case x = 1 |
| 53 | +} |
| 54 | + |
| 55 | +public protocol TestRefinedProto: BadProto { // expected-error {{public protocol cannot refine an internal protocol}} |
| 56 | +// expected-note @-1 {{protocol 'BadProto' is imported by this file as 'internal' from 'BADLibrary'}} |
| 57 | +} |
| 58 | + |
| 59 | +package class TestSubclassPackage: BadClass { // expected-error {{class cannot be declared package because its superclass is internal}} |
| 60 | +// expected-note @-1 {{class 'BadClass' is imported by this file as 'internal' from 'BADLibrary'}} |
| 61 | +} |
| 62 | + |
| 63 | +package enum TestRawTypePackage: IntLike { // expected-error {{enum cannot be declared package because its raw type uses an internal type}} |
| 64 | +// expected-note @-1 {{struct 'IntLike' is imported by this file as 'internal' from 'BADLibrary'}} |
| 65 | + case x = 1 |
| 66 | +} |
| 67 | + |
| 68 | +package protocol TestRefinedProtoPackage: BadProto { // expected-error {{package protocol cannot refine an internal protocol}} |
| 69 | +// expected-note @-1 {{protocol 'BadProto' is imported by this file as 'internal' from 'BADLibrary'}} |
| 70 | +} |
0 commit comments