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

Narrowed down property causes compilation failure #335

Open
Schahen opened this issue Jul 21, 2020 · 1 comment · May be fixed by #338
Open

Narrowed down property causes compilation failure #335

Schahen opened this issue Jul 21, 2020 · 1 comment · May be fixed by #338
Assignees
Labels
compilation-failure kotlin code is generated but this code fails to be compiled domain:override missing overrides, redundant overrides, duplicate overrides etc.
Milestone

Comments

@Schahen
Copy link
Contributor

Schahen commented Jul 21, 2020

Consider following code:

interface Result {}
interface SpecifiedResult extends Result {}

export interface SchedulerLike {
    now: () => Result;
}

export declare class Scheduler implements SchedulerLike {
    now: () => SpecifiedResult;
}

as of now it's converted to:

@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS")

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 Result

external interface SpecifiedResult : Result

external interface SchedulerLike {
    var now: () -> Result
}

external open class Scheduler : SchedulerLike {
    override var now: () -> SpecifiedResult
}

Which will fail to compile with:

a/b.module_tmp.kt:27:23: error: type of 'now' doesn't match the type of the overridden var-property 'public abstract var now: () -> Result defined in SchedulerLike'
    override var now: () -> SpecifiedResult

Let's discuss what we actually want to do in such case, because as of now I see two options:
#1 replace override var now: () -> SpecifiedResult with just var now: () -> Result
#2 use val

We should actually thoroughly think through all this stuff - right now I'm not sure what would be a better option and even whether we are limited with only these two options.

@Schahen Schahen added compilation-failure kotlin code is generated but this code fails to be compiled domain:override missing overrides, redundant overrides, duplicate overrides etc. labels Jul 21, 2020
@Schahen Schahen added this to the 0.5.8 milestone Jul 21, 2020
@trilis trilis linked a pull request Aug 4, 2020 that will close this issue
@trilis trilis changed the title Narrowed down lambda property causes compilation failure Narrowed down property causes compilation failure Aug 4, 2020
@trilis
Copy link
Contributor

trilis commented Aug 4, 2020

This actually happens with all narrowed down types of var-properties, not only lambdas

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants