tracker issue : CF-4198489

select a category, or use search below
(searches all categories and all time range)

Properties defined in parent class should be inherited as variables of subclass

| View in Tracker

Status/Resolution/Reason: To Fix//Investigate

Reporter/Name(from Bugbase): Ross McMahon / Ross McMahon ()

Created: 04/06/2017

Components: Language, Scopes

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: 11+ /

Priority/Frequency: Normal / Some users will encounter

Locale/System: / Platforms All

Vote Count: 7

Problem Description: When extending objects, any properties defined in the parent should be inherited as variables of the child, as when properties are defined in the child they are put into the variables scope - inherited ones are not.

Steps to Reproduce:


component name="parentClass" accessors="true"{

  property name="id" type="numeric" default=0;



component name="childClass" accessors="true" extends="parentClass"{

  public string function example(){


var child = new childClass();

Actual Result: Element ID is undefined in variables

Expected Result: 0

Any Workarounds: Explicitly setting = getID() in parentClass constructor method. Or using Lucee, which inherits correctly.



oops, should be extends="parent" and var child = new child();
Comment by Ross M.
955 | April 06, 2017 12:08:39 PM GMT
Needless to say, this works in the other application server not to be named here.
Vote by Evagoras C.
956 | April 06, 2017 12:08:48 PM GMT
This should work, checked in CF2016 and has the same issue.
Vote by John W.
957 | April 06, 2017 12:12:54 PM GMT
Vote by Adam C.
958 | May 04, 2017 11:48:31 AM GMT
FWIW, the component `mappedSuperClass` attribute might be the intended solution for this. Although having to define this at all goes against typical inheritance practices. While this attribute is specifically for ORM, it might work with non-persisted extends, I'm not sure. > If set to yes on a non-persistent CFC, child CFCs can inherit its properties. For example, you can define a base CFC with common properties such as ID, version, or createdOn which all other persistent CFCs would extend and thus get one common behavior.mappedSuperClass cannot be set to yes on a persistent CFC.
Comment by Ryan P.
30445 | March 07, 2019 03:51:06 PM GMT