Skip to content

Add diagnostic if deinits have names and parameters #959

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

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 17, 2022

No description provided.

@ahoppen ahoppen requested a review from bnbarham October 17, 2022 11:02
@ahoppen ahoppen force-pushed the ahoppen/deinits-with-name branch from 1b57308 to 820768b Compare October 17, 2022 12:33
@ahoppen
Copy link
Member Author

ahoppen commented Oct 17, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit 583e3d8 into swiftlang:main Oct 17, 2022
@ahoppen ahoppen deleted the ahoppen/deinits-with-name branch October 17, 2022 13:56
DiagnosticSpec(message: "deinitializers cannot have parameters", fixIts: ["remove function signature"]),
], fixedSource: """
class FooClassDeinitializerA {
deinit{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate that we remove the trailing trivia here. But adding it in would make the deinit x(a: Int) { case look silly instead 🤷.

@@ -403,4 +393,14 @@ final class InitDeinitTests: XCTestCase {
)
}

func testDeinitInSwiftinterfaceIsFollowedByFinalFunc() {
AssertParse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check the structure here? This could also be parsed as

deinit final
func foo()

depending on recovery. Do we already have:

class Foo {
  func foo() final
  func bar()
}

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants