Files
swift-mirror/test/Sema/enum_raw_representable_object_literals.swift
Pavel Yaskevich 93a75d72a7 [Tests] NFC: Update Sema/enum_raw_representable_object_literals.swift
This is follow-up to https://github.com/swiftlang/swift/pull/82275.
The test in question is enabled only on iOS so it slipped through.
2025-06-18 00:21:00 -07:00

20 lines
971 B
Swift

// RUN: %target-typecheck-verify-swift
// REQUIRES: OS=ios
import UIKit
struct FooLiteral: _ExpressibleByColorLiteral, _ExpressibleByImageLiteral, _ExpressibleByFileReferenceLiteral {
init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {}
init(imageLiteralResourceName: String) {}
init(fileReferenceLiteralResourceName: String) {}
}
enum Foo: FooLiteral { // expected-error {{raw type 'FooLiteral' is not expressible by a string, integer, or floating-point literal}}
typealias RawValue = Never
var rawValue: Never { fatalError() }
init(rawValue: Never) { fatalError() }
case bar1 = #colorLiteral(red: 1, green: 0, blue: 0, alpha: 1) // expected-error {{raw value for enum case must be a literal}}
case bar2 = #imageLiteral(resourceName: "hello.png") // expected-error {{raw value for enum case must be a literal}}
case bar3 = #fileLiteral(resourceName: "what.txt") // expected-error {{raw value for enum case must be a literal}}
}