Skip to content

Commit 7796815

Browse files
address review comments
1 parent 10b2b0f commit 7796815

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

joern-cli/frontends/swiftsrc2cpg/src/test/scala/io/joern/swiftsrc2cpg/passes/ast/CallTests.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ class CallTests extends SwiftCompilerSrc2CpgSuite {
3535
val List(barCall) = cpg.call.nameExact("bar").l
3636
barCall.methodFullName shouldBe x2cpg.Defines.DynamicCallUnknownFullName
3737
barCall.signature shouldBe ""
38+
barCall.dispatchType shouldBe DispatchTypes.DYNAMIC_DISPATCH
39+
3840
val List(barCallReceiverCall) = barCall.receiver.isIdentifier.l
3941
barCallReceiverCall.name shouldBe "self"
4042
barCallReceiverCall.typeFullName shouldBe "Sources/main.swift:<global>.Foo"
4143

4244
val List(methodCall) = cpg.call.nameExact("method").l
4345
methodCall.methodFullName shouldBe x2cpg.Defines.DynamicCallUnknownFullName
4446
methodCall.signature shouldBe ""
47+
methodCall.dispatchType shouldBe DispatchTypes.DYNAMIC_DISPATCH
48+
4549
val List(methodCallReceiverCall) = methodCall.receiver.isIdentifier.l
4650
methodCallReceiverCall.name shouldBe "other"
4751
methodCallReceiverCall.typeFullName shouldBe "ANY"
@@ -64,13 +68,17 @@ class CallTests extends SwiftCompilerSrc2CpgSuite {
6468
val List(fooCall) = cpg.call.nameExact("foo").l
6569
fooCall.methodFullName shouldBe "SwiftTest.Foo.foo:()->()"
6670
fooCall.signature shouldBe "()->()"
71+
fooCall.dispatchType shouldBe DispatchTypes.DYNAMIC_DISPATCH
72+
6773
val List(fooCallReceiver) = fooCall.receiver.isIdentifier.l
6874
fooCallReceiver.name shouldBe "self"
6975
fooCallReceiver.typeFullName shouldBe "SwiftTest.Foo"
7076

7177
val List(barCall) = cpg.call.nameExact("bar").l
7278
barCall.methodFullName shouldBe "SwiftTest.Foo.bar:()->Swift.String"
7379
barCall.signature shouldBe "()->Swift.String"
80+
barCall.dispatchType shouldBe DispatchTypes.DYNAMIC_DISPATCH
81+
7482
val List(barCallReceiverCall) = barCall.receiver.isIdentifier.l
7583
barCallReceiverCall.name shouldBe "self"
7684
barCallReceiverCall.typeFullName shouldBe "SwiftTest.Foo"

joern-cli/frontends/swiftsrc2cpg/src/test/scala/io/joern/swiftsrc2cpg/utils/SwiftCompilerTests.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,10 @@ class SwiftCompilerTests extends AnyWordSpec with Matchers {
597597
Some("SwiftHelloWorldLib.HelloWorld.init()->SwiftHelloWorldLib.HelloWorld")
598598
)
599599
)
600-
mainMappings should contain(
601-
("func_decl", (67, 155), Some("Swift.Void"), Some("SwiftHelloWorld.Main.main()->()"))
600+
mainMappings should contain oneElementOf List(
601+
("func_decl", (67, 155), Some("Swift.Void"), Some("SwiftHelloWorld.Main.main()->()")),
602+
// TODO: in preparation for Swift 6.2.x migration, Void changed to () just like in the function signature
603+
("func_decl", (67, 155), Some("()"), Some("SwiftHelloWorld.Main.main()->()"))
602604
)
603605
mainMappings should contain(("var_decl", (102, 102), Some("SwiftHelloWorldLib.HelloWorld"), None))
604606

0 commit comments

Comments
 (0)