Skip to content

Rule to check for Swift 5-mode-incompatible API #5987

@mattmassicotte

Description

@mattmassicotte

New Issue Checklist

Feature or Enhancement Proposal

There are a number of ways to break compatibility with Swift 5 mode (strict concurrency off) that are difficult to notice. Here are some examples:

@MainActor
public class MainThreadOnly {}

public func takeBlock(_ block: @Sendable () - Void)
public func takeGlobalBlock(_ block: @MainActor () - Void)

In all of these cases, to preserve compatibility you must use @preconcurrency.

@preconcurrency @MainActor
public class MainThreadOnly {}

@preconcurrency 
public func takeBlock(_ block: @Sendable () - Void)

@preconcurrency 
public func takeGlobalBlock(_ block: @MainActor () - Void)

I think this could be a great new rule!

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule-requestRequests for a new rules.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions