Hi, I have following problem with calling private method inside constructor chain:
I have two class in hiearchy with both have setupProperties private method.
setupProperties
@Js class Animal { new make() { echo("Animal.make() $this.hash") setupProperties } private Void setupProperties() { echo("Animal.setupProperties() $this.hash") } }
@Js class Lion : Animal { new make() : super() { echo("Lion.make() $this.hash") setupProperties } private Void setupProperties() { echo("Lion.setupProperties() $this.hash") } }
I have following test case class:
@Js class TestConstructorChainJs : Test { Void testIt() { a := Animal() echo("--------------") b := Lion() } }
When running generated bytecode everything is OK:
~/IdeaProjects/fantom-test % fant fantomtest -- Run: fantomtest::TestConstructorChainJs.testIt... Animal.make() 1601025338 Animal.setupProperties() 1601025338 -------------- Animal.make() 1236688438 Animal.setupProperties() 1236688438 Lion.make() 1236688438 Lion.setupProperties() 1236688438 Pass: fantomtest::TestConstructorChainJs.testIt [0] Time: 28ms *** *** All tests passed! [1 tests, 1 methods, 0 verifies] ***
But when running generated JS wrong setupProperties method is called:
~/IdeaProjects/fantom-test % fan compilerJs::TestRunner fantomtest -- Run: fantomtest::TestConstructorChainJs.testIt... Animal.make() -9007199254740992 Animal.setupProperties() -9007199254740992 -------------- Animal.make() -9007199254740991 Lion.setupProperties() -9007199254740991 Lion.make() -9007199254740991 Lion.setupProperties() -9007199254740991 Pass: fantomtest::TestConstructorChainJs.testIt [0] Time: 65ms *** *** All tests passed! [1 tests, 1 methods, 0 verifies] ***
Looks like this is old but known issue: #1651
Yes this is a known issue - we should at least update compilerJs in the meantime to warn for those cases. I thought I had done that - but I guess not - will take a look.
Ok, I will try to live with that ;-)
Login or Signup to reply.
bedla Thu 15 Nov 2012
Hi, I have following problem with calling private method inside constructor chain:
I have two class in hiearchy with both have
setupProperties
private method.I have following test case class:
When running generated bytecode everything is OK:
But when running generated JS wrong
setupProperties
method is called:Yuri Strot Thu 15 Nov 2012
Looks like this is old but known issue: #1651
andy Thu 15 Nov 2012
Yes this is a known issue - we should at least update compilerJs in the meantime to warn for those cases. I thought I had done that - but I guess not - will take a look.
bedla Thu 15 Nov 2012
Ok, I will try to live with that ;-)