diff --git a/lib/Sema/TypeChecker.cpp b/lib/Sema/TypeChecker.cpp index 024ad6a3bc9f6..258d9e8c83f09 100644 --- a/lib/Sema/TypeChecker.cpp +++ b/lib/Sema/TypeChecker.cpp @@ -172,7 +172,7 @@ DeclName TypeChecker::getObjectLiteralConstructorName(ObjectLiteralExpr *expr) { switch (expr->getLiteralKind()) { case ObjectLiteralExpr::colorLiteral: { return DeclName(Context, Context.Id_init, - { Context.getIdentifier("colorLiteralRed"), + { Context.getIdentifier("_colorLiteralRed"), Context.getIdentifier("green"), Context.getIdentifier("blue"), Context.getIdentifier("alpha") }); diff --git a/stdlib/public/SDK/AppKit/AppKit.swift b/stdlib/public/SDK/AppKit/AppKit.swift index ba9298bd4fa67..d225eec07b9bd 100644 --- a/stdlib/public/SDK/AppKit/AppKit.swift +++ b/stdlib/public/SDK/AppKit/AppKit.swift @@ -79,7 +79,7 @@ extension NSApplication { extension NSColor : _ExpressibleByColorLiteral { @nonobjc - public required convenience init(colorLiteralRed red: Float, green: Float, + public required convenience init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) { self.init(srgbRed: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha)) diff --git a/stdlib/public/SDK/CoreGraphics/CoreGraphics.swift b/stdlib/public/SDK/CoreGraphics/CoreGraphics.swift index 96943ce274069..7ed88df501bb6 100644 --- a/stdlib/public/SDK/CoreGraphics/CoreGraphics.swift +++ b/stdlib/public/SDK/CoreGraphics/CoreGraphics.swift @@ -53,7 +53,7 @@ public protocol _CGColorInitTrampoline { } extension _CGColorInitTrampoline { - public init(colorLiteralRed red: Float, green: Float, blue: Float, + public init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) { self.init(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha)) diff --git a/stdlib/public/SDK/UIKit/UIKit.swift b/stdlib/public/SDK/UIKit/UIKit.swift index f37db95da49a3..90b4ccdf996b6 100644 --- a/stdlib/public/SDK/UIKit/UIKit.swift +++ b/stdlib/public/SDK/UIKit/UIKit.swift @@ -216,7 +216,7 @@ extension UIView : _DefaultCustomPlaygroundQuickLookable { #endif extension UIColor : _ExpressibleByColorLiteral { - @nonobjc public required convenience init(colorLiteralRed red: Float, + @nonobjc public required convenience init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) { self.init(red: CGFloat(red), green: CGFloat(green), diff --git a/stdlib/public/core/CompilerProtocols.swift b/stdlib/public/core/CompilerProtocols.swift index 38a7a7ea77de0..2eb12b3bc1223 100644 --- a/stdlib/public/core/CompilerProtocols.swift +++ b/stdlib/public/core/CompilerProtocols.swift @@ -744,7 +744,18 @@ public protocol _ExpressibleByColorLiteral { /// /// Do not call this initializer directly. Instead, initialize a variable or /// constant using a color literal. - init(colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) + init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) +} + +extension _ExpressibleByColorLiteral { + @available(swift, deprecated: 3.2, obsoleted: 4.0, + message: "This initializer is only meant to be used by color literals") + public init( + colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float + ) { + self.init( + _colorLiteralRed: red, green: green, blue: blue, alpha: alpha) + } } /// A type that can be initialized using an image literal (e.g. diff --git a/test/IDE/complete_literal.swift b/test/IDE/complete_literal.swift index f49fb3e811476..9134e3247ef52 100644 --- a/test/IDE/complete_literal.swift +++ b/test/IDE/complete_literal.swift @@ -62,7 +62,7 @@ func giveMeAString() -> Int { // LITERAL5-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: append({#contentsOf: Sequence#})[#Void#]{{; name=.+$}} struct MyColor: _ExpressibleByColorLiteral { - init(colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) { red = colorLiteralRed } + init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) { red = colorLiteralRed } var red: Float } public typealias _ColorLiteralType = MyColor diff --git a/test/IDE/complete_value_literals.swift b/test/IDE/complete_value_literals.swift index 4397299a73f20..6f02d3e002fd3 100644 --- a/test/IDE/complete_value_literals.swift +++ b/test/IDE/complete_value_literals.swift @@ -201,7 +201,7 @@ func testTuple2() { // TUPLE_2: Literal[Tuple]/None/TypeRelation[Identical]: ({#(values)#})[#(MyInt1, MyString1, MyDouble1)#]; struct MyColor1: _ExpressibleByColorLiteral { - init(colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} + init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} } func testColor0() { let x: Int = #^COLOR_0^# diff --git a/test/IDE/structure_object_literals.swift b/test/IDE/structure_object_literals.swift index ed0bc3fc20475..3144ff3b28dd5 100644 --- a/test/IDE/structure_object_literals.swift +++ b/test/IDE/structure_object_literals.swift @@ -1,7 +1,7 @@ // RUN: %swift-ide-test -structure -source-filename %s | %FileCheck %s struct S: _ExpressibleByColorLiteral { - init(colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} + init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} } // CHECK: let y: S = #colorLiteral(red: 1, green: 0, blue: 0, alpha: 1) diff --git a/test/Sema/object_literals_ios.swift b/test/Sema/object_literals_ios.swift index 9aea7d0822a32..7585a96d0122b 100644 --- a/test/Sema/object_literals_ios.swift +++ b/test/Sema/object_literals_ios.swift @@ -2,7 +2,7 @@ // REQUIRES: OS=ios struct S: _ExpressibleByColorLiteral { - init(colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} + init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} } let y: S = #colorLiteral(red: 1, green: 0, blue: 0, alpha: 1) diff --git a/test/Sema/object_literals_osx.swift b/test/Sema/object_literals_osx.swift index 6d4c67b8590bb..d5eb0c6aee18c 100644 --- a/test/Sema/object_literals_osx.swift +++ b/test/Sema/object_literals_osx.swift @@ -2,7 +2,7 @@ // REQUIRES: OS=macosx struct S: _ExpressibleByColorLiteral { - init(colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} + init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} } let y: S = #colorLiteral(red: 1, green: 0, blue: 0, alpha: 1)