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 overload on unrolling union type containing both string literal and string #306

Closed
Schahen opened this issue Jun 10, 2020 · 1 comment
Labels
ir-target causes problems with IR compilation
Milestone

Comments

@Schahen
Copy link
Contributor

Schahen commented Jun 10, 2020

this code:

declare namespace api {
  type CalendarKey = 'sameDay' | 'nextDay' | 'lastDay' | 'nextWeek' | 'lastWeek' | 'sameElse' | string;

  interface Locale {
    calendar(key?: CalendarKey): string;
  }
}

export = api;

is converted to:

package api

external interface Locale {
    fun calendar(key: String /* 'sameDay' | 'nextDay' | 'lastDay' | 'nextWeek' | 'lastWeek' | 'sameElse' */ = definedExternally): String
    fun calendar(key: String = definedExternally): String
    fun calendar(): String
}

hence a conflicting overload.
I'm surprised to see CalendarKey definition at first place (for me it's equivalent to just declaring string) but still this shouldn't be the case - this should be merged.

@Schahen Schahen added the ir-target causes problems with IR compilation label Jun 10, 2020
@Schahen Schahen added this to the 0.5.2 milestone Jun 10, 2020
@Schahen
Copy link
Contributor Author

Schahen commented Jun 10, 2020

The same, of course, happens with numeric literals as well:

@file:JsModule("tmp")
@file:JsNonModule
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")
package api

import kotlin.js.*
import kotlin.js.Json
import org.khronos.webgl.*
import org.w3c.dom.*
import org.w3c.dom.events.*
import org.w3c.dom.parsing.*
import org.w3c.dom.svg.*
import org.w3c.dom.url.*
import org.w3c.fetch.*
import org.w3c.files.*
import org.w3c.notifications.*
import org.w3c.performance.*
import org.w3c.workers.*
import org.w3c.xhr.*

external interface Locale {
    fun calendar(key: Number /* 1 | 3 | 5 | 7 */ = definedExternally): String
    fun calendar(key: Number = definedExternally): String
    fun calendar(): String
}

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