Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11664] Getting "Expression type '()' is ambiguous without more context" when using @propertyWrapper #54073

Closed
swift-ci opened this issue Oct 24, 2019 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself property wrappers Feature: property wrappers type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11664
Radar rdar://problem/56584397
Original Reporter RomanPodymov (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Xcode 11.1, Swift 5.1.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, PropertyWrappers, TypeChecker
Assignee RomanPodymov (JIRA)
Priority Medium

md5: 85608e7aafd274573da331f95bab48c9

relates to:

  • SR-11654 Optional wrapped property can't be passed to generic function

Issue Description:

Consider the following code:

protocol P {
    func f()
}
 
struct S: P {
    func f() { }
}
 
func f(p: P) {
    p.f()
}
 
class C {
    @Wrapper
    var s: S = S()
 
    func g() {
        f(p: s)
    }
}
 
@propertyWrapper
struct Wrapper {
    private let value: S
 
    public init(wrappedValue: S) {
        value = wrappedValue
    }
 
    var wrappedValue: S {
        return value
    }
}

As for me this code is correct. However getting Expression type '()' is ambiguous without more context for f(p: s). Temporal solution is to replace f(p: s) with f(p: s as P).

@belkadan
Copy link
Contributor

Possibly the same underlying cause as SR-11654?

@swift-ci create

@theblixguy
Copy link
Collaborator

Works on master, so maybe it got fixed a while ago

@beccadax
Copy link
Contributor

I reproduced this in Xcode 11.1 and 11.2 beta, but not with a master toolchain from earlier this month.

@typesanitizer
Copy link

Marking as resolved since it looks like this has been fixed on master. You can download a recent master snapshot toolchain from swift.org (https://swift.org/download/#snapshots) and check that it works correctly.

@swift-ci
Copy link
Collaborator Author

Comment by Roman Podymov (JIRA)

The issue is not reproducing in Swift 5.2/Xcode 11.4 beta.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself property wrappers Feature: property wrappers type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants