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

Redundant overloads are causing compilation issues #275

Closed
Schahen opened this issue Apr 29, 2020 · 2 comments
Closed

Redundant overloads are causing compilation issues #275

Schahen opened this issue Apr 29, 2020 · 2 comments
Assignees
Labels
compilation-failure kotlin code is generated but this code fails to be compiled domain:override missing overrides, redundant overrides, duplicate overrides etc. ir-target causes problems with IR compilation
Milestone

Comments

@Schahen
Copy link
Contributor

Schahen commented Apr 29, 2020

This code:

declare namespace API {
  interface EmitterA { }
  interface EmitterB { }

  interface Domain  {
    add(emitter: EmitterA | EmitterB): void;
    remove(emitter: EmitterA | EmitterB): void;
  }

  class SubDomain implements API.Domain {
    add(emitter: API.EmitterA | API.EmitterB): void;
    remove(emitter: API.EmitterA | API.EmitterB): void;
  }
}

is converted to

external interface EmitterA

external interface EmitterB

external interface Domain {
    fun add(emitter: EmitterA)
    fun add(emitter: EmitterB)
    fun remove(emitter: EmitterA)
    fun remove(emitter: EmitterB)
}

external open class SubDomain : Domain {
    override fun add(emitter: EmitterA)
    override fun add(emitter: EmitterB)
    override fun remove(emitter: EmitterA)
    override fun remove(emitter: EmitterB)
    override fun add(emitter: EmitterA)
    override fun add(emitter: EmitterB)
    override fun remove(emitter: EmitterA)
    override fun remove(emitter: EmitterB)
}

This redundant method duplicated make it impossible to compile without @file:Suppress("CONFLICTING_OVERLOADS") for old backend and completely impossible to compile for IR backend.

@Schahen Schahen added compilation-failure kotlin code is generated but this code fails to be compiled ir-target causes problems with IR compilation labels Apr 29, 2020
@Schahen
Copy link
Contributor Author

Schahen commented May 6, 2020

Though it looks very similar, there's probability that following problem is not related at leas directly, still I decided to post it here so far.

Following code:

/// <reference path="_domain.d.ts" />

declare module "events" {
  class internal extends NodeJS.EventEmitter { }

  namespace internal {
    class EventEmitter extends internal {
    }
  }

  export = internal;
}

declare namespace NodeJS {
  interface Timer {}

  class EventEmitter {
  }

  interface Domain extends EventEmitter {
    add(emitter: EventEmitter): void;
  }
}

// _domain.d.ts
declare module "domain" {
    import * as events from "events";

    class Domain implements NodeJS.Domain {
        add(emitter: events.EventEmitter): void;
    }
}

will produce following code for Domain:

external open class Domain : NodeJS.Domain {
    open fun add(emitter: EventEmitter)
    override fun add(emitter: EventEmitter)
}

Which I'm honestly shocked with.

@Schahen Schahen closed this as completed May 6, 2020
@Schahen Schahen reopened this May 6, 2020
@Schahen Schahen added the domain:override missing overrides, redundant overrides, duplicate overrides etc. label May 13, 2020
Schahen added a commit that referenced this issue May 14, 2020
This relates to #275 and is intentionally simplified - ideally we won't have this lowering at all since it's struggle with consequences, not the actual reason.

Aber Schritt für Schritt!
@Schahen Schahen added this to the 5.0.1 milestone May 28, 2020
@Schahen Schahen modified the milestones: 0.5.1, 0.5.2 Jun 5, 2020
@Schahen Schahen modified the milestones: 0.5.2, 0.5.3 Jun 13, 2020
@Schahen Schahen modified the milestones: 0.5.3, 0.5.7, 0.5.8 Jul 15, 2020
@trilis
Copy link
Contributor

trilis commented Aug 10, 2020

Regarding second problem, it produces correct code for me, so it was probably fixed at some point. First problem still reproduces, though

@trilis trilis self-assigned this Aug 10, 2020
@trilis trilis linked a pull request Aug 11, 2020 that will close this issue
@trilis trilis closed this as completed Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation-failure kotlin code is generated but this code fails to be compiled domain:override missing overrides, redundant overrides, duplicate overrides etc. ir-target causes problems with IR compilation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants