Title:
Implicit accessor method invoked from extending component when accessor method is explicitly implemented.
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Brian Love / Brian Love ()
Created: 06/02/2017
Versions: 2016
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: 2016.0.04.302561 / 2018,0,0,303932
Priority/Frequency: Normal / All users will encounter
Locale/System: English / Mac 10.12
Vote Count: 2
Problem Description: Create two components: a.cfc and b.cfc, where b extends a. The parent component (a.cfc) has the attribute accessors="true" to generate implicit accessor (getter) and mutator (setter) methods. Both components override the accessor (getter) method, and the child component invokes the parent accessor method.
The expected result is that the parent accessor method that is explicitly defined would be invoked. However, the actual result is that the generated/implicit accessor is invoked.
This was not a bug in CF10 (did not test in CF11)
Steps to Reproduce:
== a.cfc ==
component accessors="true" {
property name="foo" type="string";
public function init() {
setFoo("foo");
return this;
}
public string function getFoo() {
return "a";
}
}
== b.cfc ==
component extends="a" {
public string function getFoo() {
return "#super.getFoo()# + b";
}
}
== run.cfm ==
<cfset b = new B()>
<cfoutput>B: #b.getFoo()#</cfoutput>
Actual Result: the output of run.cfm is: "foo + b"
Expected Result: the output of run.cfm should be: "a + b".
Explanation: Invoking super.getFoo() in the extending component b.cfc should execute the overridden getFoo() method in the parent component a.cfc that returns the string "a". Rather, it executes the implicit accessor method that returns the value that was set in the constructor, "foo"
Any Workarounds: By adding the getter="false" attribute to the property you can avoid having the implicit method generated.
Attachments:
- June 02, 2017 00:00:00: a.cfc
- June 02, 2017 00:00:00: b.cfc
- June 02, 2017 00:00:00: run.cfm
Comments: