Skip to content

Commit

Permalink
Merge pull request #258 from Andrew-Lees11/Swift4.0
Browse files Browse the repository at this point in the history
Feat: Add support for Swift 4.0
  • Loading branch information
djbe committed Oct 1, 2018
2 parents 01afae9 + 4154cd3 commit 4faf8f5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
@@ -1,11 +1,16 @@
matrix:
include:
- os: osx
osx_image: xcode9.2
env: SWIFT_VERSION=4.0.3
- os: osx
osx_image: xcode9.4
env: SWIFT_VERSION=4.1
- os: osx
osx_image: xcode10
env: SWIFT_VERSION=4.2
- os: linux
env: SWIFT_VERSION=4.0.3
- os: linux
env: SWIFT_VERSION=4.1
- os: linux
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
@@ -1,4 +1,4 @@
// swift-tools-version:4.1
// swift-tools-version:4.0
import PackageDescription

let package = Package(
Expand Down
38 changes: 38 additions & 0 deletions Sources/_SwiftSupport.swift
@@ -0,0 +1,38 @@
import Foundation

#if !swift(>=4.1)
public extension Sequence {
func compactMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
return try flatMap(transform)
}
}
#endif

#if !swift(>=4.1)
public extension Collection {
func index(_ i: Self.Index, offsetBy n: Int) -> Self.Index {
let indexDistance = Self.IndexDistance(n)
return index(i, offsetBy: indexDistance)
}
}
#endif

#if !swift(>=4.1)
public extension TemplateSyntaxError {
public static func ==(lhs: TemplateSyntaxError, rhs: TemplateSyntaxError) -> Bool {
return lhs.reason == rhs.reason &&
lhs.description == rhs.description &&
lhs.token == rhs.token &&
lhs.stackTrace == rhs.stackTrace &&
lhs.templateName == rhs.templateName
}
}
#endif

#if !swift(>=4.1)
public extension Variable {
public static func ==(lhs: Variable, rhs: Variable) -> Bool {
return lhs.variable == rhs.variable
}
}
#endif

0 comments on commit 4faf8f5

Please sign in to comment.