Skip to content

Commit cc3ddbf

Browse files
Merge pull request #9456 from adrian-prantl/137003294
Add a testcase for protected imports.
2 parents c18a244 + 86c1b0f commit cc3ddbf

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@_spi(Private) import B
2+
public class FromA {
3+
public init() {}
4+
@_spi(Private) public var a : Int { get { return 42 } }
5+
@_spi(Private) public var b : FromB { get { return FromB() } }
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public class FromB {
2+
public init() {}
3+
public let c = 42
4+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SWIFT_SOURCES := main.swift
2+
MODULENAME = Main
3+
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)
4+
LD_EXTRAS = -L$(BUILDDIR) -lA -lB
5+
6+
all: A.swiftmodule $(EXE)
7+
8+
include Makefile.rules
9+
10+
A.swiftmodule: $(SRCDIR)/A.swift B.swiftmodule
11+
$(MAKE) -f $(MAKEFILE_RULES) \
12+
DYLIB_ONLY=YES \
13+
DYLIB_NAME=A \
14+
DYLIB_SWIFT_SOURCES=A.swift \
15+
DYLIB_MODULENAME=A \
16+
SWIFTFLAGS_EXTRAS=-I$(BUILDDIR) \
17+
LD_EXTRAS="-L$(BUILDDIR) -lB"
18+
19+
B.swiftmodule: $(SRCDIR)/B.swift
20+
$(MAKE) -f $(MAKEFILE_RULES) \
21+
DYLIB_ONLY=YES \
22+
DYLIB_NAME=B \
23+
DYLIB_SWIFT_SOURCES=B.swift \
24+
DYLIB_MODULENAME=B
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import os
6+
7+
8+
class TestSwiftImportSPI(lldbtest.TestBase):
9+
@swiftTest
10+
def test(self):
11+
"""Test SPI imports"""
12+
self.build()
13+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
14+
self, 'break here', lldb.SBFileSpec('main.swift'),
15+
extra_images=['A', 'B'])
16+
# a.b returns a B FromB, which is an @_spi(Private) import of A.
17+
self.expect("expression -- a.b.c", substrs=['42'])
18+
# a.a itself is marked @_spi(Private).
19+
self.expect("expression -- a.a", substrs=['42'])
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import A
2+
3+
let a = FromA()
4+
print("break here")

0 commit comments

Comments
 (0)