Files
swift-mirror/test/decl/protocol/special/Error.swift
Doug Gregor 6efaf7ac0f Introduce -warn-concurrency flag to warn about concurrency issues.
To help support incremental adoption of the concurrency model, a number
of concurrency-related diagnostics are enabled only in "new" code that
takes advantage of concurrency features---async, @concurrent functions,
actors, etc. This warning flag opts into additional warnings that better
approximate the eventual concurrency model, and which will become
errors a future Swift version, allowing one to both experiment with
the full concurrency model and also properly prepare for it.
2021-03-05 10:58:54 -08:00

47 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: cp %s %t/main.swift
// RUN: %target-swift-frontend -typecheck -verify -primary-file %t/main.swift %S/Inputs/Error_other.swift
enum ClericalErrorDomain: Error {
case MisplacedDocument(name: String)
case AccidentallyErasedTape(fromMinute: Double, toMinute: Double)
}
let error
= ClericalErrorDomain.AccidentallyErasedTape(fromMinute: 5, toMinute: 23.5)
let domain: String = error._domain
let code: Int = error._code
struct UseEnumBeforeDeclaration {
let errorDomain: String = EnumToUseBeforeDeclaration.A._domain
let errorCode: Int = EnumToUseBeforeDeclaration.A._code
}
enum EnumToUseBeforeDeclaration: Error {
case A
}
let domainFromOtherFile: String = FromOtherFile.A._domain
let codeFromOtherFile: Int = AlsoFromOtherFile.A._code
enum NotAnError { case A }
let notAnErrorDomain: String = NotAnError.A._domain // expected-error{{value of type 'NotAnError' has no member '_domain'}}
let notAnErrorCode: Int = NotAnError.A._code // expected-error{{value of type 'NotAnError' has no member '_code'}}
enum EmptyErrorDomain: Error {}
struct ErrorStruct : Error {
}
class ErrorClass : Error {
}
struct ErrorStruct2 { }
extension ErrorStruct2 : Error { }
class ErrorClass2 { }
extension ErrorClass2 : Error { }