Skip to content

Commit b776075

Browse files
tejassharma96Matty Cross
authored andcommitted
Fix typed throws
1 parent 8c94a21 commit b776075

File tree

6 files changed

+44
-67
lines changed

6 files changed

+44
-67
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ jobs:
5656
run: |
5757
make
5858
set -o pipefail && xcodebuild test -scheme "Cuckoo-iOS" -workspace Cuckoo.xcworkspace \
59-
-destination "platform=iOS Simulator,name=iPhone 16,OS=18.0" \
59+
-destination "platform=iOS Simulator,name=iPhone 16,OS=18.6" \
6060
| xcbeautify --renderer github-actions

.package.resolved

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "8490d2acd8ad9e7bf6832b02450dc4d8c86e8c0e58ba9d99e8dddf1b356f0adb",
2+
"originHash" : "0f9b850de3674fd03811448f333777e55faf9d883255578b0e357ca2e3eb23cb",
33
"pins" : [
44
{
55
"identity" : "aexml",
@@ -64,40 +64,13 @@
6464
"version" : "1.2.3"
6565
}
6666
},
67-
{
68-
"identity" : "swift-cmark",
69-
"kind" : "remoteSourceControl",
70-
"location" : "https://github.com/apple/swift-cmark.git",
71-
"state" : {
72-
"revision" : "3ccff77b2dc5b96b77db3da0d68d28068593fa53",
73-
"version" : "0.5.0"
74-
}
75-
},
76-
{
77-
"identity" : "swift-format",
78-
"kind" : "remoteSourceControl",
79-
"location" : "https://github.com/swiftlang/swift-format",
80-
"state" : {
81-
"revision" : "83248b4fa37919f78ffbd4650946759bcc54c2b5",
82-
"version" : "509.0.0"
83-
}
84-
},
85-
{
86-
"identity" : "swift-markdown",
87-
"kind" : "remoteSourceControl",
88-
"location" : "https://github.com/apple/swift-markdown.git",
89-
"state" : {
90-
"revision" : "8f79cb175981458a0a27e76cb42fee8e17b1a993",
91-
"version" : "0.5.0"
92-
}
93-
},
9467
{
9568
"identity" : "swift-syntax",
9669
"kind" : "remoteSourceControl",
9770
"location" : "https://github.com/swiftlang/swift-syntax",
9871
"state" : {
99-
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
100-
"version" : "509.0.0"
72+
"revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2",
73+
"version" : "601.0.1"
10174
}
10275
},
10376
{

Generator/Generator.xcodeproj/project.pbxproj

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
436B1158A6ED217E8D5B05A2 /* Method.swift in Sources */ = {isa = PBXBuildFile; fileRef = 200EDE7B95DE3AE27C29CC42 /* Method.swift */; };
3939
440C1F66A6749F51752B99FB /* MethodParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B0CEC0E6BC2F8FDDCB86A7C /* MethodParameter.swift */; };
4040
44A72AF2F6D6D2E1D371C50F /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 82A76F6C4BC47C860A90EFA7 /* ArgumentParser */; };
41-
46D9663497017BFABAA09B66 /* SwiftSyntax in Frameworks */ = {isa = PBXBuildFile; productRef = 10B6A078051BAD502FBAC752 /* SwiftSyntax */; };
41+
46D9663497017BFABAA09B66 /* SwiftParser in Frameworks */ = {isa = PBXBuildFile; productRef = 8EE13525838522D454E8E20E /* SwiftParser */; };
4242
48205DE8188B258737270530 /* ModifierListSyntax+common.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF4E1D009F8E0D6988EA56E9 /* ModifierListSyntax+common.swift */; };
4343
4871C1D4211262913FE7E23A /* TOMLKit in Frameworks */ = {isa = PBXBuildFile; productRef = CF01AE9B482B793213C15803 /* TOMLKit */; };
4444
4A04C8DABB34967D6D2EDB49 /* OrderedSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1F3CD491EFD856B4C96AC7 /* OrderedSet.swift */; };
@@ -70,7 +70,7 @@
7070
7BA0A80747083052F5C13CFA /* Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20DEC997DE9F9A496DC55AF3 /* Accessibility.swift */; };
7171
7CD4072067DCEE2A688103E8 /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B8A800560013CEEAC82BDD3 /* Attribute.swift */; };
7272
7E252699C077ACF9FD291F1A /* Module.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E5104F422D2332A72E71E80 /* Module.swift */; };
73-
7EA8FCCFD03F056EC363708E /* SwiftFormat in Frameworks */ = {isa = PBXBuildFile; productRef = 2690FAF509B9294F9963CFC6 /* SwiftFormat */; };
73+
7EA8FCCFD03F056EC363708E /* SwiftSyntax in Frameworks */ = {isa = PBXBuildFile; productRef = 10B6A078051BAD502FBAC752 /* SwiftSyntax */; };
7474
846FF44141EAE708431788F6 /* FileHeaderHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0CA1F2E31C4D1F4D7E7AFCF /* FileHeaderHandler.swift */; };
7575
8540D535F2845A4E702C641C /* GenericParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63889180D5687BDF03C5808D /* GenericParameter.swift */; };
7676
874D43E3025261D20346F043 /* Templates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64FF786D71666C925DDDD02F /* Templates.swift */; };
@@ -98,7 +98,7 @@
9898
A287B2FC91838CF47C1A402E /* HasAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE812E30DAE3B6E5EBCFA786 /* HasAttributes.swift */; };
9999
A614B3D353A1FB249B44205F /* Array+uniquing.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87364DB21521E529206C4AF /* Array+uniquing.swift */; };
100100
A726E94D443E854CF233AB3B /* HasMembers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BE01B4BF58360B997B65AAD /* HasMembers.swift */; };
101-
A7D8BECC5EFE87BCEA01B0ED /* SwiftFormat in Frameworks */ = {isa = PBXBuildFile; productRef = 40FBF1EF4588DEF0C34CC5AA /* SwiftFormat */; };
101+
A7D8BECC5EFE87BCEA01B0ED /* SwiftSyntax in Frameworks */ = {isa = PBXBuildFile; productRef = 62225DF9A023014F74823A4D /* SwiftSyntax */; };
102102
A81CBA6691D31B0CCCFC0B03 /* MockTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C7A2FE3DED070B31815AB8 /* MockTemplate.swift */; };
103103
A82BA9AE98522CF4D219B107 /* Reference.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2038E75371E9914C0057A429 /* Reference.swift */; };
104104
A863F7D5DA2F1E539178451B /* MethodParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B0CEC0E6BC2F8FDDCB86A7C /* MethodParameter.swift */; };
@@ -134,7 +134,7 @@
134134
F9D4D3624CF450DAF961A852 /* ComplexType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D950A7A41DA6F8B7AAC81E7 /* ComplexType.swift */; };
135135
FAB2366C273E3BC994A8C856 /* Generator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17570DCB8ED56FAA7B60FFEE /* Generator.swift */; };
136136
FCB132A3412E852A169DD034 /* OrderedSetTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E931623865980B964DF83AC /* OrderedSetTest.swift */; };
137-
FCF3348DBE14EB308918B32E /* SwiftSyntax in Frameworks */ = {isa = PBXBuildFile; productRef = 62225DF9A023014F74823A4D /* SwiftSyntax */; };
137+
FCF3348DBE14EB308918B32E /* SwiftParser in Frameworks */ = {isa = PBXBuildFile; productRef = 94019ED73D1D548332CF9AA4 /* SwiftParser */; };
138138
FE1CA1D2D68ECCD53D48698E /* StubbingProxyTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E923EEB246D54BC00305580 /* StubbingProxyTemplate.swift */; };
139139
FEA8AD46EE5CF6745F088EAD /* Generator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17570DCB8ED56FAA7B60FFEE /* Generator.swift */; };
140140
FFCD2B1E9E235ED6BC916487 /* Serializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85B33943FFC685132859E72 /* Serializable.swift */; };
@@ -235,8 +235,8 @@
235235
files = (
236236
66D182220FD1D33F11E28562 /* FileKit in Frameworks */,
237237
5A27FB878DCF33CFC25C7D58 /* Stencil in Frameworks */,
238-
7EA8FCCFD03F056EC363708E /* SwiftFormat in Frameworks */,
239-
46D9663497017BFABAA09B66 /* SwiftSyntax in Frameworks */,
238+
7EA8FCCFD03F056EC363708E /* SwiftSyntax in Frameworks */,
239+
46D9663497017BFABAA09B66 /* SwiftParser in Frameworks */,
240240
44A72AF2F6D6D2E1D371C50F /* ArgumentParser in Frameworks */,
241241
4871C1D4211262913FE7E23A /* TOMLKit in Frameworks */,
242242
C51F0249FFE7914B0C2F5979 /* XcodeProj in Frameworks */,
@@ -250,8 +250,8 @@
250250
files = (
251251
8A928827A40634B369221352 /* FileKit in Frameworks */,
252252
95E7D0B5A6F8DC6D520B6763 /* Stencil in Frameworks */,
253-
A7D8BECC5EFE87BCEA01B0ED /* SwiftFormat in Frameworks */,
254-
FCF3348DBE14EB308918B32E /* SwiftSyntax in Frameworks */,
253+
A7D8BECC5EFE87BCEA01B0ED /* SwiftSyntax in Frameworks */,
254+
FCF3348DBE14EB308918B32E /* SwiftParser in Frameworks */,
255255
E6C0036B6154EEDA485EB5A6 /* ArgumentParser in Frameworks */,
256256
DB3FE43AF21614D7910CEBC9 /* TOMLKit in Frameworks */,
257257
51EC7E8DFC26826B44E514C9 /* XcodeProj in Frameworks */,
@@ -454,8 +454,8 @@
454454
packageProductDependencies = (
455455
AC6685255D5370BF08A7BA31 /* FileKit */,
456456
FA3FEB96551B01B3B12795B5 /* Stencil */,
457-
40FBF1EF4588DEF0C34CC5AA /* SwiftFormat */,
458457
62225DF9A023014F74823A4D /* SwiftSyntax */,
458+
94019ED73D1D548332CF9AA4 /* SwiftParser */,
459459
0461AA3DA9DB4A68910D1B97 /* ArgumentParser */,
460460
C443144D2084F752ABD40F7D /* TOMLKit */,
461461
7E00179A8BA49B9C8D4230FB /* XcodeProj */,
@@ -482,8 +482,8 @@
482482
packageProductDependencies = (
483483
AD2D7CEA740A2A8B936746A3 /* FileKit */,
484484
874C86044871C521F0D50492 /* Stencil */,
485-
2690FAF509B9294F9963CFC6 /* SwiftFormat */,
486485
10B6A078051BAD502FBAC752 /* SwiftSyntax */,
486+
8EE13525838522D454E8E20E /* SwiftParser */,
487487
82A76F6C4BC47C860A90EFA7 /* ArgumentParser */,
488488
CF01AE9B482B793213C15803 /* TOMLKit */,
489489
D2BFBD8FD405A61AC715D4A9 /* XcodeProj */,
@@ -518,7 +518,6 @@
518518
8B21E241BF00E2E25C38BB43 /* XCRemoteSwiftPackageReference "Stencil" */,
519519
12B435B0A49E5C757FE0FC38 /* XCRemoteSwiftPackageReference "FileKit" */,
520520
94DB3AD2FF77CD1231BF7E6C /* XCRemoteSwiftPackageReference "Rainbow" */,
521-
610CDB7DFE32B92210967C0D /* XCRemoteSwiftPackageReference "swift-format" */,
522521
4D7FC2EFCFF8100C810E9030 /* XCRemoteSwiftPackageReference "swift-syntax" */,
523522
626B8647C363F00FE034AC55 /* XCRemoteSwiftPackageReference "XcodeProj" */,
524523
);
@@ -926,17 +925,8 @@
926925
repositoryURL = "https://github.com/swiftlang/swift-syntax";
927926
requirement = {
928927
kind = versionRange;
929-
maximumVersion = 602.0.0;
930-
minimumVersion = 509.0.0;
931-
};
932-
};
933-
610CDB7DFE32B92210967C0D /* XCRemoteSwiftPackageReference "swift-format" */ = {
934-
isa = XCRemoteSwiftPackageReference;
935-
repositoryURL = "https://github.com/swiftlang/swift-format";
936-
requirement = {
937-
kind = versionRange;
938-
maximumVersion = 602.0.0;
939-
minimumVersion = 509.0.0;
928+
maximumVersion = 603.0.0;
929+
minimumVersion = 600.1.0;
940930
};
941931
};
942932
626B8647C363F00FE034AC55 /* XCRemoteSwiftPackageReference "XcodeProj" */ = {
@@ -982,14 +972,6 @@
982972
isa = XCSwiftPackageProductDependency;
983973
productName = SwiftSyntax;
984974
};
985-
2690FAF509B9294F9963CFC6 /* SwiftFormat */ = {
986-
isa = XCSwiftPackageProductDependency;
987-
productName = SwiftFormat;
988-
};
989-
40FBF1EF4588DEF0C34CC5AA /* SwiftFormat */ = {
990-
isa = XCSwiftPackageProductDependency;
991-
productName = SwiftFormat;
992-
};
993975
45417D207C5B670A21479EA0 /* Rainbow */ = {
994976
isa = XCSwiftPackageProductDependency;
995977
productName = Rainbow;
@@ -1014,6 +996,14 @@
1014996
isa = XCSwiftPackageProductDependency;
1015997
productName = Stencil;
1016998
};
999+
8EE13525838522D454E8E20E /* SwiftParser */ = {
1000+
isa = XCSwiftPackageProductDependency;
1001+
productName = SwiftParser;
1002+
};
1003+
94019ED73D1D548332CF9AA4 /* SwiftParser */ = {
1004+
isa = XCSwiftPackageProductDependency;
1005+
productName = SwiftParser;
1006+
};
10171007
AC6685255D5370BF08A7BA31 /* FileKit */ = {
10181008
isa = XCSwiftPackageProductDependency;
10191009
productName = FileKit;

Generator/Sources/Internal/Templates/MockTemplate.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extension {{ container.parentFullyQualifiedName }} {
6060
{% endif -%}
6161
6262
{% for property in container.properties %}
63-
63+
6464
{% if debug %}
6565
// {{ property }}
6666
{% endif %}
@@ -109,7 +109,7 @@ extension {{ container.parentFullyQualifiedName }} {
109109
{{ initializer.accessibility|withSpace }}required init{{initializer.signature}} {}
110110
{% endfor %}
111111
{% for method in container.methods %}
112-
112+
113113
{% if debug %}
114114
// {{method}}
115115
{% endif %}
@@ -124,7 +124,9 @@ extension {{ container.parentFullyQualifiedName }} {
124124
"{{method.fullyQualifiedName}}",
125125
parameters: ({{method.parameterNames}}),
126126
escapingParameters: ({{method.escapingParameterNames}}),
127-
{% if method.throwsOnly %}errorType: {{ method.throwTypeError }}.self,{% endif %}
127+
{% if method.throwsOnly %}
128+
errorType: {{ method.throwTypeError }}.self,
129+
{% endif %}
128130
superclassCall: {%+ if container.isImplementation %}{% if method.isAsync %}await {%+ endif %}super.{{method.name}}({{method.call}}){% else %}Cuckoo.MockManager.crashOnProtocolSuperclassCall(){% endif %},
129131
defaultCall: {%+ if method.isAsync %}await {%+ endif %}__defaultImplStub!.{{method.name}}{%if method.isOptional %}!{%endif%}({{method.call}})
130132
){{ method.parameters|closeNestedClosure }}

Generator/Sources/Internal/Tokens/ThrowType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ enum ThrowType: CustomStringConvertible, Equatable {
5858
var type: String {
5959
switch self {
6060
case .throws(let type):
61-
return type ?? "Error"
61+
return type ?? "Swift.Error"
6262
case .rethrows:
63-
return "Error"
63+
return "Swift.Error"
6464
}
6565
}
6666
}
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
struct StubError: Error {}
22

33
class ClassWithTypedThrows {
4-
func typedThrows() throws(StubError) -> Int? {
4+
enum Error: Swift.Error {
5+
case failed
6+
}
7+
8+
func typedThrows() throws(Error) -> Int? {
59
return nil
610
}
711

812
func genericWithTypedThrows<T>(_ value: T) throws(StubError) {}
13+
14+
func asyncTypedThrow() async throws(Error) -> Int? {
15+
return nil
16+
}
17+
18+
func asyncGenericWithTypedThrows<T>(_ value: T) async throws(StubError) {}
19+
20+
func untypedThrows() throws {}
921
}

0 commit comments

Comments
 (0)