Skip to content

Ambiguous use of 'getValue' error when adding RawRepresentable conformance to Date #26

@Coffeemate

Description

@Coffeemate

I needed to add a RawRepresentable conformance to Date but it triggered compile errors:

  • Ambiguous use of 'getValue'
  • Ambiguous use of 'setValue'

Here's a code example:

import Foundation
import ObservableDefaults

@ObservableDefaults
final class UserDefaultsSettings {
  var date = Date()
}

extension Date: @retroactive RawRepresentable {
  public typealias RawValue = Int
  
  public var rawValue: Int {
    return Int(timeIntervalSince1970)
  }
  
  public init(rawValue: Int) {
    self.init(timeIntervalSince1970: TimeInterval(rawValue))
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions