Tuesday, August 16, 2022
HomeiOS Developmentios - Xcode 14 beta 4 - warnings about unused return values...

ios – Xcode 14 beta 4 – warnings about unused return values even when utilizing @discardableResult


In Xcode 14 beta 4 (and maybe earlier betas however I have not checked) I am seeing warnings about unused return values although the strategies are annotated with @discardableResult. These warnings solely floor for async strategies, and so far as I can inform, solely in extensions on UIKit courses:

import UIKit

extension UIView {
  @discardableResult
  func discardableUIKit() async -> Int {
    42
  }

  @discardableResult
  func discardableUIKit() -> Int {
    42
  }
}

extension NSObject {
  @discardableResult
  func discardableNSObject() async -> Int {
    42
  }

  @discardableResult
  func discardableNSObject() -> Int {
    42
  }
}

extension NSNumber {
  @discardableResult
  func discardableNSNumber() async -> Int {
    42
  }

  @discardableResult
  func discardableNSNumber() -> Int {
    42
  }
}

func take a look at() {
  UIView().discardableUIKit()
  NSNumber().discardableNSObject()
  NSNumber().discardableNSNumber()
  Job {
    await UIView().discardableUIKit() // Results of name to operate returning 'Int' is unused
    await NSNumber().discardableNSObject()
    await NSNumber().discardableNSNumber()
  }
}

I do not see these warnings in Xcode 13. Is that this a bug or one thing new to Xcode 14/Swift 5.7 that I am unaware of?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular