Files
swift-mirror/test/decl/protocol/async_requirements.swift
Doug Gregor 293e31658c Prefer witnesses with no difference effects to ones that have fewer effects.
One can overload on async vs. non-async, and the constraint solver has a
preference rule based on context. Extend that preference rule to
witness matching, so we prefer a witness that exactly matches the
effects of the requirement to one that has fewer effects.

Fixes rdar://84034057.
2021-11-08 16:36:39 -08:00

38 lines
619 B
Swift

// RUN: %target-typecheck-verify-swift -disable-availability-checking
// Ensure that a protocol with async requirements can be conformed to by
// non-async requirements, and that overloading works.
protocol A {
func foo()
func foo() async
init()
init() async
var property: Int { get async }
func bar() throws
func bar() async throws
}
struct A1: A {
func foo() { }
var property: Int = 17
func bar() { }
}
struct A2: A {
func foo() { }
func foo() async { }
init() { }
init() async { }
var property: Int { get async { 5 } }
func bar() throws { }
func bar() async throws { }
}