Skip to content

Commit a50f997

Browse files
use strings instead of substrings in associated values for ToolsVersionLoader.Error cases
`String` is a currency type in Swift. `Substring` is not.
1 parent b370960 commit a50f997

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/Commands/SwiftPackageTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ extension SwiftPackageTool {
489489
case .set(let value):
490490
guard let toolsVersion = ToolsVersion(string: value) else {
491491
// FIXME: Probably lift this error defination to ToolsVersion.
492-
throw ToolsVersionLoader.Error.malformedToolsVersionSpecification(.versionSpecifier(value[...]))
492+
throw ToolsVersionLoader.Error.malformedToolsVersionSpecification(.versionSpecifier(value))
493493
}
494494
try writeToolsVersion(at: pkg, version: toolsVersion, fs: localFileSystem)
495495

Sources/PackageLoading/ToolsVersionLoader.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ public class ToolsVersionLoader: ToolsVersionLoaderProtocol {
135135
/// The version specifier is missing.
136136
case missingVersionSpecifier
137137
/// The comment marker is malformed.
138-
case commentMarker(_ commentMarker: Substring)
138+
case commentMarker(_ commentMarker: String)
139139
/// The label part of the Swift tools version specification is malformed.
140-
case label(_ label: Substring)
140+
case label(_ label: String)
141141
/// The version specifier is malformed.
142-
case versionSpecifier(_ versionSpecifier: Substring)
142+
case versionSpecifier(_ versionSpecifier: String)
143143
}
144144

145145
/// Details of backward-incompatible contents with Swift tools version ≤ 5.3.
@@ -339,11 +339,11 @@ public class ToolsVersionLoader: ToolsVersionLoaderProtocol {
339339

340340
guard toolsVersionSpecificationComponents.everythingUpToVersionSpecifierIsWellFormed else {
341341
if commentMarker != "//" {
342-
throw Error.malformedToolsVersionSpecification(.commentMarker(commentMarker))
342+
throw Error.malformedToolsVersionSpecification(.commentMarker(String(commentMarker)))
343343
}
344344

345345
if label.lowercased() != "swift-tools-version:" {
346-
throw Error.malformedToolsVersionSpecification(.label(label))
346+
throw Error.malformedToolsVersionSpecification(.label(String(label)))
347347
}
348348

349349
// The above If-statements should have covered all possible malformations in Swift tools version specification up to the version specifier.
@@ -352,7 +352,7 @@ public class ToolsVersionLoader: ToolsVersionLoaderProtocol {
352352
}
353353

354354
guard let version = ToolsVersion(string: String(versionSpecifier)) else {
355-
throw Error.malformedToolsVersionSpecification(.versionSpecifier(versionSpecifier))
355+
throw Error.malformedToolsVersionSpecification(.versionSpecifier(String(versionSpecifier)))
356356
}
357357

358358
guard version > .v5_3 || manifestComponents.isCompatibleWithPreSwift5_3_1 else {

0 commit comments

Comments
 (0)