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-9178] Duplicate diagnostic when applying @escaping or @autoclosure to a generic param type #51669

Closed
hamishknight opened this issue Nov 4, 2018 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-9178
Radar None
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Swift version 4.2-dev (LLVM b70847456e, Clang 86404441b8, Swift 17808c32fe)
Target: x86_64-apple-darwin17.7.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @theblixguy
Priority Medium

md5: ab6c051f8dfd9b94303b45b7ebd2d70d

Issue Description:

Both of the following get duplicate diagnostics:

func foo<T>(_ x: @escaping T) {}
func bar<T>(_ x: @autoclosure T) {}
/Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:325:19: error: @escaping attribute only applies to function types
func foo<T>(_ x: @escaping T) {}
                 ~^~~~~~~~~

/Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:325:19: error: @escaping attribute only applies to function types
func foo<T>(_ x: @escaping T) {}
                 ~^~~~~~~~~

/Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:327:19: error: @autoclosure attribute only applies to function types
func bar<T>(_ x: @autoclosure T) {}
                  ^
/Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:327:19: error: @autoclosure attribute only applies to function types
func bar<T>(_ x: @autoclosure T) {}
@belkadan
Copy link
Contributor

belkadan commented Nov 5, 2018

cc @xedin

@xedin
Copy link
Member

xedin commented Nov 5, 2018

/cc @rintaro All of these diagnostics are related to parser I think (or resolveType*) do you have any ideas why would it be repeating like that?

@rintaro
Copy link
Mannequin

rintaro mannequin commented Nov 6, 2018

These diagnostics are from TypeResolver::resolveAttributedType().

Because TypeResolver::resolveAttributedType() does not invalidate invalid attributes, resolving type for the same typerepr twice results duplicated diagnostics.

In this case, it's from TypeChecker::validateGenericFuncSignature().
In this method, checkGenericFuncSignature() is called twice (one is via computeGenericFuncSignature()).

@theblixguy
Copy link
Collaborator

Fixed on master by #28888 Please verify using the next development snapshot!

@hamishknight
Copy link
Collaborator Author

Thanks Suyash!

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants