Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
fix alias collisions by parameterizing the alias names
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Aug 21, 2017
1 parent e3dcd3d commit 01698b6
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
enum UIColor { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
#endif

// swiftlint:disable file_length
Expand Down
6 changes: 2 additions & 4 deletions Tests/Expected/Colors/literals-swift3-context-defaults.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
enum ColorName { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
enum ColorName { }
#endif

Expand Down
6 changes: 2 additions & 4 deletions Tests/Expected/Colors/literals-swift3-context-multiple.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
enum ColorName { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
enum ColorName { }
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
enum UIColor { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
#endif

// swiftlint:disable file_length
Expand Down
6 changes: 2 additions & 4 deletions Tests/Expected/Colors/literals-swift4-context-defaults.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
enum ColorName { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
enum ColorName { }
#endif

Expand Down
6 changes: 2 additions & 4 deletions Tests/Expected/Colors/literals-swift4-context-multiple.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
enum ColorName { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
enum ColorName { }
#endif

Expand Down
2 changes: 0 additions & 2 deletions Tests/Expected/XCAssets/swift2-context-all-customname.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias Image = UIImage
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias Image = UIImage
#endif

Expand Down
2 changes: 0 additions & 2 deletions Tests/Expected/XCAssets/swift2-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias Image = UIImage
#endif

Expand Down
10 changes: 5 additions & 5 deletions Tests/Expected/XCAssets/swift3-context-all-customname.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif

Expand Down Expand Up @@ -37,8 +37,8 @@ struct XCTColorAsset {

#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: Color {
return Color(asset: self)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
#endif
}
Expand Down Expand Up @@ -120,7 +120,7 @@ extension Image {
}
}

extension Color {
extension AssetColorTypeAlias {
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: XCTColorAsset) {
Expand Down
10 changes: 5 additions & 5 deletions Tests/Expected/XCAssets/swift3-context-all-no-all-values.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif

Expand Down Expand Up @@ -37,8 +37,8 @@ struct ColorAsset {

#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: Color {
return Color(asset: self)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
#endif
}
Expand Down Expand Up @@ -90,7 +90,7 @@ extension Image {
}
}

extension Color {
extension AssetColorTypeAlias {
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
Expand Down
10 changes: 5 additions & 5 deletions Tests/Expected/XCAssets/swift3-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif

Expand Down Expand Up @@ -37,8 +37,8 @@ struct ColorAsset {

#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: Color {
return Color(asset: self)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
#endif
}
Expand Down Expand Up @@ -120,7 +120,7 @@ extension Image {
}
}

extension Color {
extension AssetColorTypeAlias {
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
Expand Down
10 changes: 5 additions & 5 deletions Tests/Expected/XCAssets/swift4-context-all-customname.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif

Expand Down Expand Up @@ -36,8 +36,8 @@ struct XCTColorAsset {
fileprivate var name: String

@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: Color {
return Color(asset: self)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
}

Expand Down Expand Up @@ -120,7 +120,7 @@ extension Image {
}
}

extension Color {
extension AssetColorTypeAlias {
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: XCTColorAsset) {
let bundle = Bundle(for: BundleToken.self)
Expand Down
10 changes: 5 additions & 5 deletions Tests/Expected/XCAssets/swift4-context-all-no-all-values.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif

Expand Down Expand Up @@ -36,8 +36,8 @@ struct ColorAsset {
fileprivate var name: String

@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: Color {
return Color(asset: self)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
}

Expand Down Expand Up @@ -90,7 +90,7 @@ extension Image {
}
}

extension Color {
extension AssetColorTypeAlias {
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
let bundle = Bundle(for: BundleToken.self)
Expand Down
10 changes: 5 additions & 5 deletions Tests/Expected/XCAssets/swift4-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#if os(OSX)
import AppKit.NSImage
typealias Color = NSColor
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias Color = UIColor
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif

Expand Down Expand Up @@ -36,8 +36,8 @@ struct ColorAsset {
fileprivate var name: String

@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: Color {
return Color(asset: self)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
}

Expand Down Expand Up @@ -120,7 +120,7 @@ extension Image {
}
}

extension Color {
extension AssetColorTypeAlias {
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
let bundle = Bundle(for: BundleToken.self)
Expand Down
6 changes: 2 additions & 4 deletions templates/colors/literals-swift3.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
{% if palettes %}
{% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
{% if enumName != 'NSColor' %}enum {{enumName}} { }{% endif %}
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
{% if enumName != 'UIColor' %}enum {{enumName}} { }{% endif %}
#endif

Expand Down
6 changes: 2 additions & 4 deletions templates/colors/literals-swift4.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
{% if palettes %}
{% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
import AppKit
{% if enumName != 'NSColor' %}enum {{enumName}} { }{% endif %}
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
import UIKit
{% if enumName != 'UIColor' %}enum {{enumName}} { }{% endif %}
#endif

Expand Down
Loading

0 comments on commit 01698b6

Please sign in to comment.