Swift: add a test case showing module loading problem

Extractor fails to load separate modules that were built by another
version of an actual compiler.
This commit is contained in:
Alex Denisov
2022-06-21 16:58:13 +02:00
parent 6c68872163
commit 57811a4efc
11 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
// swift-tools-version: 5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "A",
products: [
.library(
name: "A",
targets: ["A"]),
],
targets: [
.target(
name: "A",
dependencies: []),
]
)

View File

@@ -0,0 +1,5 @@
public struct A {
public private(set) var text = Atext
public init() {}
}

View File

@@ -0,0 +1 @@
let Atext = "Hello, A"

View File

@@ -0,0 +1,18 @@
// swift-tools-version: 5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "B",
products: [
.library(
name: "B",
targets: ["B"]),
],
targets: [
.target(
name: "B",
dependencies: []),
]
)

View File

@@ -0,0 +1,5 @@
public struct B {
public private(set) var text = Btext
public init() {}
}

View File

@@ -0,0 +1 @@
let Btext = "Hello, B"

View File

@@ -0,0 +1,23 @@
// swift-tools-version: 5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "partial-modules",
products: [
.library(
name: "partial-modules",
targets: ["partial-modules"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(path: "./A"),
.package(path: "./B"),
],
targets: [
.target(
name: "partial-modules",
dependencies: ["A", "B"]),
]
)

View File

@@ -0,0 +1,11 @@
import A
import B
public struct partial_modules {
public init() {
let a = A()
let b = B()
print(a.text)
print(b.text)
}
}

View File

@@ -0,0 +1,4 @@
import swift
from UnresolvedDotExpr e
select e

View File

@@ -0,0 +1,7 @@
from create_database_utils import *
run_codeql_database_create([
'env',
'swift package clean',
'swift build'
], lang='swift', keep_trap=True)