Skip to content

Not sure if the compiler can do runtime polymorphism #2

@RoySRC

Description

@RoySRC
class A {
  public static void main(String[] args) {
    C b;
    b = new B();
    System.out.println(b.a());
  }
}

class B extends C {
  int a;
  public int a() {
    int c;
    c = this.c();
    a = 12 * c;
    return a;
  }
}

class C {
  int c;

  public int c() {
    c = 12;
    return c;
  }
}

should print 144. In order to perform runtime polymorphism we need to implement a vTable. The compiler at this stage has no such implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions