#1947 js: Compiler not handling super.constField in ctor correctly

SlimerDude Wed 11 Jul 2012

Using Fantom 1.0.63 the following:

@Js
class Screen : Canvas {
  new make() {
    super.doubleBuffered = true
  }
}

when compiled to JS gives

fan.fwt.Canvas.prototype.doubleBuffered$ is undefined

which I figure is wrong! In the mean time, as a workaround, I'm using this:

if (Env.cur.runtime != "js")
  super.doubleBuffered = true

Steve.

andy Wed 11 Jul 2012

That actually might be a bug in the compiler. Does this work?

@Js
class Screen : Canvas {
  new make() {
    doubleBuffered = true
  }
}

SlimerDude Wed 11 Jul 2012

Yep, it works without the super.

andy Wed 11 Jul 2012

Promoted to ticket #1947 and assigned to andy

Ok - thats a bug in how the compiler handles const fields.

andy Wed 11 Jul 2012

Renamed from fan.fwt.Canvas.prototype.doubleBuffered$ is undefined to js: Compiler not handling super.constField in ctor correctly

SlimerDude Wed 25 Jul 2012

It seems it's not limited to const fields or ctors either.

@Js
abstract class Viewer {
  Obj renderer { private set }
}

@Js
class LayerViewer : Viewer {
  Void stuff() {
    super.renderer.toStr
  }
}

gives an m_renderer is undefined error.

SlimerDude Wed 25 Jul 2012

Hmm... it seems I use super a lot(!) For the purpose of getting my app working in JS, I can delete most of them (I just loose a little readability) but I'm stumped with this:

@Js
abstract class Viewer {
  virtual Bool pillarRiserMode := false
}

@Js
abstract class MapViewer : Viewer {
  override Bool pillarRiserMode {
    set {
      super.pillarRiserMode = it
      // other stuff
    }
  }
}

How do I override the field and set the parent value?

Edit: Or even override a method and call the parent method?

Login or Signup to reply.