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

Check that there are not static and non-static members with the same name #427

Closed
rix0rrr opened this issue Apr 3, 2019 · 3 comments
Closed

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Apr 3, 2019

It's definitely not allowed in Java, but probably is allowed in TypeScript, so jsii should guard against it.

@skinny85
Copy link
Contributor

skinny85 commented Apr 3, 2019

Yes, it's definitely allowed in TypeScript. I ran into this doing the rename of all L1 classes to add the Cfn prefix - I had an isReference static method and an isReference property in the same class. The pacmak build for C# was the only thing that caught it.

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Apr 4, 2019

While we're at it, we should guard against having statics with the same name as a class we're inheriting from.

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Apr 4, 2019

Okay I'm not sure about the second one actually. Java allows this:

class Henk {
  public static void henk() {
    System.out.println("Inherited henk");
  }
}

class Main extends Henk {
  public static void main(String[] args) {
    Main.henk();
  }
}

C# does too:

using System;

class Henk {
  public static void henk() {
    Console.WriteLine ("Inherited Henk");
  }
}

class MainClass : Henk {
  public static void Main (string[] args) {
    MainClass.henk();
  }
}

Works the same in TypeScript:

class Henk {
  public static henk() {
    console.log('Inherited henk');
  }
}

class Main extends Henk {

}

Main.henk();

I don't see any problem.

rix0rrr pushed a commit that referenced this issue Apr 4, 2019
This is not allowed in Java, and leads to compiler warnings in C#.

Fixes #427.
rix0rrr added a commit that referenced this issue Apr 4, 2019
…#430)

This is not allowed in Java, and leads to compiler warnings in C#.

Fixes #427.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants