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

Private members overwriting each other (prototype version) #10

Closed
ikasiuk opened this issue Jan 4, 2012 · 2 comments
Closed

Private members overwriting each other (prototype version) #10

ikasiuk opened this issue Jan 4, 2012 · 2 comments

Comments

@ikasiuk
Copy link
Member

ikasiuk commented Jan 4, 2012

With the "prototype" version, the following program prints 2 although it should print 1:

class Type1() {
    Integer i = 1;
    shared void test() { print(i); }
}
class Type2() extends Type1() {
    Integer i = 2;
}
void run() {
    Type2 tst = Type2();
    tst.test();
}

That's because both members i get mapped to a variable this.i of the same JS object.

ikasiuk added a commit that referenced this issue Jan 7, 2012
ikasiuk added a commit that referenced this issue Jan 8, 2012
@ikasiuk ikasiuk closed this as completed in c28f66a Jan 8, 2012
@ikasiuk
Copy link
Member Author

ikasiuk commented Jan 8, 2012

Member names for non-shared members now have "$TypeName" appended to them in the JS code. But this solution probably needs to be revised later because it likely doesn't work if the derived class has the same name as the base class, only in a different package.

@gavinking
Copy link
Member

Yes, great, that's the right solution. Thanks.

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