[InterfaceGen] Print @discardableResult in generated interfaces

Resolves rdar://58805969.
This commit is contained in:
Ben Barham
2022-08-15 16:34:33 -07:00
parent a3b351e53c
commit 46d12f8b51
5 changed files with 1115 additions and 1051 deletions

View File

@@ -615,7 +615,6 @@ struct PrintOptions {
result.SkipPrivateStdlibDecls = true;
result.SkipUnderscoredStdlibProtocols = true;
result.SkipDeinit = true;
result.ExcludeAttrList.push_back(DAK_DiscardableResult);
result.EmptyLineBetweenMembers = true;
result.CascadeDocComment = true;
result.ShouldQualifyNestedDeclarations =

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,8 @@ public class MyClass {
private func priv_method() {}
}
public func pub_function() {}
@discardableResult
public func pub_function() -> Int { return 0 }
internal func int_function() {}
fileprivate func fp_function() {}
private func priv_function() {}

View File

@@ -9,7 +9,8 @@ public protocol MyProto<Assoc> {
associatedtype Assoc
}
public func pub_function()
@discardableResult
public func pub_function() -> Int
[
@@ -76,17 +77,27 @@ public func pub_function()
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 119,
key.length: 18
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 138,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 126,
key.offset: 145,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 131,
key.offset: 150,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
key.offset: 168,
key.length: 3
}
]
[
@@ -94,6 +105,12 @@ public func pub_function()
key.kind: source.lang.swift.ref.associatedtype,
key.offset: 81,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.offset: 168,
key.length: 3,
key.is_system: 1
}
]
[
@@ -166,15 +183,21 @@ public func pub_function()
key.kind: source.lang.swift.decl.function.free,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "pub_function()",
key.offset: 126,
key.length: 19,
key.nameoffset: 131,
key.offset: 145,
key.length: 26,
key.typename: "Int",
key.nameoffset: 150,
key.namelength: 14,
key.attributes: [
{
key.offset: 119,
key.offset: 138,
key.length: 6,
key.attribute: source.decl.attribute.public
},
{
key.offset: 119,
key.length: 18,
key.attribute: source.decl.attribute.discardableResult
}
]
}

View File

@@ -10,7 +10,8 @@ public protocol MyProto<Assoc> {
associatedtype Assoc
}
public func pub_function()
@discardableResult
public func pub_function() -> Int
[
@@ -87,17 +88,27 @@ public func pub_function()
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 144,
key.length: 18
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 163,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 151,
key.offset: 170,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 156,
key.offset: 175,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
key.offset: 193,
key.length: 3
}
]
[
@@ -111,6 +122,12 @@ public func pub_function()
key.kind: source.lang.swift.ref.associatedtype,
key.offset: 106,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.offset: 193,
key.length: 3,
key.is_system: 1
}
]
[
@@ -183,15 +200,21 @@ public func pub_function()
key.kind: source.lang.swift.decl.function.free,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "pub_function()",
key.offset: 151,
key.length: 19,
key.nameoffset: 156,
key.offset: 170,
key.length: 26,
key.typename: "Int",
key.nameoffset: 175,
key.namelength: 14,
key.attributes: [
{
key.offset: 144,
key.offset: 163,
key.length: 6,
key.attribute: source.decl.attribute.public
},
{
key.offset: 144,
key.length: 18,
key.attribute: source.decl.attribute.discardableResult
}
]
}