-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Previous ID | SR-13350 |
Radar | rdar://problem/66581584 |
Original Reporter | Peter_Schorn (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Duplicate |
Environment
Xcode Version 11.6 (11E708)
macOS 10.15.6
Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
Additional Detail from JIRA
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: c145292c88b0c80e3366b424ca791f0b
duplicates:
- SR-12132 @_exported does not respect custom operators
Issue Description:
Suppose you have a library with two targets: "Numerics" and "ReadModule". "Realmodule" has a public function named "realModuleTest". "Numerics" has a single file with the following line:
@_exported import RealModule
When you `import Numerics` into your project, you get access to "realModuleTest". This, as far as I understand, is the whole point of `@_exported import`.
However, when you define a custom operator inside of "RealModule", it does not get properly exported to "Numerics". Here is the custom operator I defined:
// RealModule/Real.swift
import Foundation
precedencegroup ExponentiativePrecedence {
associativity: right
higherThan: MultiplicationPrecedence
}
infix operator ** : ExponentiativePrecedence
public func ** (base: Double, power: Double) -> Double {
return pow(base, power)
}
public func realModuleTest() {
print("this function is defined in the real module")
}
I have uploaded this package to github: https://github.com/Peter-Schorn/OperatorAccessPackage
Please import the package into a command-line project and add the following to main.swift:
// main.swift
import Foundation
import Numerics
let x = 2.0
let y = 3.0
realModuleTest() // works as expected
print(x ** y) // error: "Operator is not a known binary operator"
You get the weird error described above. Surely this must be a bug, right?
UPDATE: I tried defining a custom infix and prefix operator and found that both were exported just fine. Therefore, this must be specific to infix operators.