Files
swift-mirror/test/Constraints/unapplied_method_in_property_init.swift
Kathy Gray 9f5e1a5f36 [Diagnostic] remove tautalogical error message
In simplify, we were not using the provided function apply depth to 
pass to resolve overload in all circumstances but setting a default
that did not apply when the function is provided as an argument.

By changing this to the given function apply depth, this corrects
behaviour in resolve overload and record overload to remove labels
when appropriate and thus not produce error messages with the same
function type appearing twice in conversion fixes.
2026-07-06 12:23:14 +01:00

24 lines
1.4 KiB
Swift

// RUN: %target-typecheck-verify-swift -module-name main -language-mode 5 -verify-additional-prefix swift5-
// RUN: %target-typecheck-verify-swift -module-name main -language-mode 6 -verify-additional-prefix swift6-
struct S {
func foo(c: S) -> S {}
func bar(_ c: S) -> S {}
// The different diagnostics here are due to the inference of @Sendable when attempting to reference the decl on the type rather than instance.
let x1: ((S) -> S).Type = type(of: foo)
// expected-swift5-error@-1 {{cannot convert value of type '((S) -> (S) -> S).Type' to specified type '((S) -> S).Type'}}
// expected-swift6-error@-2 {{cannot use instance member 'foo' within property initializer; property initializers run before 'self' is available}}
let x2: ((S) -> S).Type = type(of: bar)
// expected-swift5-error@-1 {{cannot convert value of type '((S) -> (S) -> S).Type' to specified type '((S) -> S).Type'}}
// expected-swift6-error@-2 {{cannot use instance member 'bar' within property initializer; property initializers run before 'self' is available}}
// https://github.com/swiftlang/swift/issues/89920
let y1: (S) -> S = foo
// expected-error@-1 {{cannot use instance member 'foo' within property initializer; property initializers run before 'self' is available}}
let y2: (S) -> S = bar
// expected-error@-1 {{cannot use instance member 'bar' within property initializer; property initializers run before 'self' is available}}
}