Skip to content

Enable method overloading and overriding #70

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

AprupKale
Copy link
Contributor

Enable running multiple classes in java-slang.

Enable method overloading and overriding to support code as follows:

public class Main {
  public void f(int x) {
    System.out.println("Instance int: " + x);
  }
  public void f(double x) {
    System.out.println("Instance double: " + x);
  }
  public static void main(String[] args) {
    Main obj = new Main();
    obj.f(5);
    obj.f(5.5);
  }
}

and

class Parent {
  public static void staticMethod() {
    System.out.println("Parent static method");
  }
  public void instanceMethod() {
    System.out.println("Parent instance method");
  }
}

class Child extends Parent {
  public static void staticMethod() {
    System.out.println("Child static method");
  }
  public void instanceMethod() {
    System.out.println("Child instance method");
  }
}

public class Main {
  public static void main(String[] args) {
    Parent.staticMethod(); // Parent static method
    Child.staticMethod(); // Child static method
    Parent ref = new Child();
    ref.instanceMethod(); // Child instance method
  }
}

@AprupKale AprupKale self-assigned this Apr 6, 2025
@AprupKale AprupKale added the enhancement New feature or request label Apr 6, 2025
@AprupKale AprupKale linked an issue Apr 6, 2025 that may be closed by this pull request
Copy link

github-actions bot commented Apr 6, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
74.64% (+0.69% 🔼)
7628/10220
🟡 Branches
61.12% (+0.73% 🔼)
2553/4177
🟡 Functions
70.53% (+1.08% 🔼)
1357/1924
🟡 Lines
75.53% (+0.59% 🔼)
7181/9508
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / assignmentExpression.test.ts
100% 100% 100% 100%
🟢
... / castExpression.test.ts
100% 100% 100% 100%
🟢
... / switch.test.ts
100% 100% 100% 100%
🟢
... / methodOverloading.test.ts
100% 100% 100% 100%
🟢
... / methodOverriding.test.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / index.ts
70.8% (-3.57% 🔻)
48% (-5.01% 🔻)
91.67% (-3.99% 🔻)
79.3% (-4.94% 🔻)
🟢
... / symbol-table.ts
93.07% (-0.83% 🔻)
76.09% (-3.32% 🔻)
100%
92.67% (-0.96% 🔻)
🟢
... / code-generator.ts
92.84% (-1.57% 🔻)
80.39% (-4.27% 🔻)
96.34% (+3.16% 🔼)
92.86% (-1.89% 🔻)

Test suite run success

1182 tests passing in 64 suites.

Report generated by 🧪jest coverage report action from d2517b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler/type checker: Support for inheritance needed
1 participant