Saltarelle / SaltarelleCompiler

C# to JavaScript compiler – Now http://bridge.net
http://saltarelle-compiler.com
Other
297 stars 74 forks source link

strict mode error when implementing interface method overloads #421

Open nippur72 opened 9 years ago

nippur72 commented 9 years ago

I'm trying to implement IPromise:

public class FakePromise : IPromise
{
    public void Then(Delegate fulfilledHandler)
    {
    }

    public void Then(Delegate fulfilledHandler, Delegate errorHandler)
    {
    }

    public void Then(Delegate fulfilledHandler, Delegate errorHandler, Delegate progressHandler)
    {
    }
}

but I get a browser error: unallowed multiple properties definition in strict mode

I think it's because it gets transpiled to:

ss.initClass($FakePromise, $asm, {
        then: function(fulfilledHandler) {
        },
        then: function(fulfilledHandler, errorHandler) {
        },
        then: function(fulfilledHandler, errorHandler, progressHandler) {
        }
    });
erik-kallen commented 9 years ago

That's an unintended consequence.

I think that if you use the roslyn branch, things will work better in this case (because there is only one Then method, which is possible due to improved optional arguments support)

erik-kallen commented 9 years ago

You might get away with specifying [NonScriptable] on some of the methods in your implementing class.

nippur72 commented 9 years ago

yes, that fixes it.