Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12318] api-digester claims that adding an enum case isn't API breaking #54748

Open
weissi opened this issue Mar 4, 2020 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@weissi
Copy link
Member

weissi commented Mar 4, 2020

Previous ID SR-12318
Radar rdar://problem/60041622
Original Reporter @weissi
Type Bug

Attachment: Download

Environment
$ jw-swift-latest swift -version
Apple Swift version 5.2-dev (LLVM 011be41f7b, Swift 13487edd09)
Target: x86_64-apple-darwin19.4.0
Additional Detail from JIRA
Votes 1
Component/s Source Tooling
Labels Bug
Assignee None
Priority Medium

md5: aac5b041f0a03897e47b0fa2b5f78011

Issue Description:

Unfortunately, swift-api-digester doesn't consider adding an enum case as API breaking but it very much is (unless you run in the "library evolution" language dialect which no SwiftPM packages are using):

Consider this package:

$ git show 1.0.0:Sources/mypkg/mypkg.swift 
struct mypkg {
    var text = "Hello, World!"
}

public enum Foo {
    case one
}
$ git show master:Sources/mypkg/mypkg.swift 
struct mypkg {
    var text = "Hello, World!"
}

public enum Foo {
    case one
    case two
}

so in 1.0.0 we only have case one and on master we additionally have two. But api-digester claims:

/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-03-03-a.xctoolchain/usr/bin/swift-api-digester -diagnose-sdk --input-paths /private/tmp/mypkg/.build/x86_64-apple-macosx/apidiff/1.0.0.json -input-paths /private/tmp/mypkg/.build/x86_64-apple-macosx/apidiff/current.json

/* Generic Signature Changes */

/* RawRepresentable Changes */

/* Removed Decls */

/* Moved Decls */

/* Renamed Decls */

/* Type Changes */

/* Decl Attribute changes */

/* Fixed-layout Type Changes */

/* Protocol Conformance Change */

/* Protocol Requirement Change */

/* Class Inheritance Change */

If I manually diff the json files, I can see that there's actually a difference

$ diff -u .build//x86_64-apple-macosx/apidiff/1.0.0.json .build//x86_64-apple-macosx/apidiff/current.json 
--- .build//x86_64-apple-macosx/apidiff/1.0.0.json  2020-03-04 16:26:13.000000000 +0000
+++ .build//x86_64-apple-macosx/apidiff/current.json    2020-03-04 16:18:42.000000000 +0000
@@ -52,6 +52,49 @@
           "moduleName": "mypkg"
         },
         {
+          "kind": "Var",
+          "name": "two",
+          "printedName": "two",
+          "children": [
+            {
+              "kind": "TypeFunc",
+              "name": "Function",
+              "printedName": "(mypkg.Foo.Type) -> mypkg.Foo",
+              "children": [
+                {
+                  "kind": "TypeNominal",
+                  "name": "Foo",
+                  "printedName": "mypkg.Foo",
+                  "usr": "s:5mypkg3FooO"
+                },
+                {
+                  "kind": "TypeNominal",
+                  "name": "Paren",
+                  "printedName": "(mypkg.Foo.Type)",
+                  "children": [
+                    {
+                      "kind": "TypeNominal",
+                      "name": "Metatype",
+                      "printedName": "mypkg.Foo.Type",
+                      "children": [
+                        {
+                          "kind": "TypeNominal",
+                          "name": "Foo",
+                          "printedName": "mypkg.Foo",
+                          "usr": "s:5mypkg3FooO"
+                        }
+                      ]
+                    }
+                  ]
+                }
+              ]
+            }
+          ],
+          "declKind": "EnumElement",
+          "usr": "s:5mypkg3FooO3twoyA2CmF",
+          "moduleName": "mypkg"
+        },
+        {
           "kind": "Function",
           "name": "__derived_enum_equals",
           "printedName": "__derived_enum_equals(_:_:)",
@@ -167,7 +210,7 @@
   "tool_arguments": [
     "-dump-sdk",
     "-I",
-    "\/private\/tmp\/mypkg\/.build\/x86_64-apple-macosx\/apidiff\/1.0.0\/.build\/debug",
+    "\/private\/tmp\/mypkg\/.build\/x86_64-apple-macosx\/debug",
     "-sdk",
     "\/redacted\/Xcode.app\/Contents\/Developer\/Platforms\/MacOSX.platform\/Developer\/SDKs\/MacOSX10.16.sdk",
     "-F",
@@ -179,7 +222,7 @@
     "-module",
     "mypkg",
     "-o",
-    "\/private\/tmp\/mypkg\/.build\/x86_64-apple-macosx\/apidiff\/1.0.0.json",
+    "\/private\/tmp\/mypkg\/.build\/x86_64-apple-macosx\/apidiff\/current.json",
     "-sdk-version",
     "redacted"
   ]

please find the package attached too

@weissi
Copy link
Member Author

weissi commented Mar 4, 2020

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant