Skip to content

[swift2objc] Support throws on methods returning primitive types #1761

Closed
@liamappelbe

Description

@liamappelbe

Hitting this compile error when trying to support the throws annotation:

pkgs/swift2objc/test/integration/throws_output.swift:16:21: error: throwing method cannot be marked @objc because it returns a value of type 'Int'; return 'Void' or a type that bridges to an Objective-C class
  @objc public func intMethod(y: Int) throws -> Int {

Looks like functions and methods that return primitive types can't be marked both @objc and throws. This is similar to #1743. The fix in both cases is to return a boxed primitive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueA good starting issue for contributors (issues with this label will appear in /contribute)package:swift2objc

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions