Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting overloads are not resolved for functions #268

Closed
Schahen opened this issue Apr 27, 2020 · 0 comments
Closed

Conflicting overloads are not resolved for functions #268

Schahen opened this issue Apr 27, 2020 · 0 comments
Labels
ir-target causes problems with IR compilation

Comments

@Schahen
Copy link
Contributor

Schahen commented Apr 27, 2020

Following code

declare function addListener(event: "disconnect", listener: (worker: Vorker) => void): Kluster;
declare function addListener(event: "online", listener: (worker: Vorker) => void): Kluster;

is translated to:

external fun addListener(event: String /* "disconnect" */, listener: (worker: Vorker) -> Unit): Kluster
external fun addListener(event: String /* "online" */, listener: (worker: Vorker) -> Unit): Kluster

And actually those two declarations are equivalent and won't compile without CONFLICTING_OVERLOADS annotation. This particular annotation exists for historical reasons and and actually was used in ts2kt as well. Actually we consistently eliminating places in code whe thing like conflicting overloads can happen.

For instance:

declare class DisposableNetworkEvent {
  once(event: string, listener: (...args: any[]) => void): this;
  once(event: "disconnect", listener: () => void): this;
  once(event: "error", listener: (error: Error) => void): this;
  once(event: "exit", listener: (code: number, signal: string) => void): this;
  once(event: "online", listener: () => void): this;
}

Is converted to:

external open class DisposableNetworkEvent {
    open fun once(event: String, listener: (args: Array<Any>) -> Unit): DisposableNetworkEvent /* this */
    open fun once(event: String, listener: () -> Unit): DisposableNetworkEvent /* this */
    open fun once(event: String /* "error" */, listener: (error: Error) -> Unit): DisposableNetworkEvent /* this */
    open fun once(event: String /* "exit" */, listener: (code: Number, signal: String) -> Unit): DisposableNetworkEvent /* this */
}

Still because of the CONFLICTING_OVERLOADS I've felt relatively safe, realising that there can be some scenarios where this was missed.

However in IR this particular annotation is not supported and won't be supported, since it's a sin and we tend not to sin in IR.

@Schahen Schahen added the ir-target causes problems with IR compilation label Apr 27, 2020
Schahen added a commit that referenced this issue Apr 27, 2020
@Schahen Schahen closed this as completed Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ir-target causes problems with IR compilation
Projects
None yet
Development

No branches or pull requests

1 participant