D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2853 - Property overriding problem
Summary: Property overriding problem
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-18 18:57 UTC by Fractal
Modified: 2019-09-10 09:17 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Fractal 2009-04-18 18:57:25 UTC
class Base
{
	int number() { return _number; } // getter
	int number(int value) { return _number; } // setter
	
private:
	int _number;
}

class Extension: Base
{	
	override int number(int value) 	// override setter
	{
		return 0; 
	}
	
	void method()
	{
		printNumber(this.number); // call base getter

                // main.d(21): Error: function main.Extension.number (int) does not match parameter types ()
                // main.d(21): Error: expected 1 arguments, not 0
	}
}

Tries call overrided setter
Comment 1 Koroskin Denis 2009-04-18 19:23:40 UTC
Fake properties must die, all I can say.
Comment 2 Witold Baryluk 2010-02-05 06:01:31 UTC
Actually setter in the base class is not needed to trigger this bug.

Also calling this.number() in method(), so adding call brackets, doesn't solve problem. So it is not only problem with setter/getter. This can lead to problem with perfectly valid code with no properties.
Comment 3 RazvanN 2019-09-10 09:17:42 UTC
This bug report is invalid. You have to use alias to pull in the number overload set to Extension.

class Extension: Base
{
        alias number = Base.number;	
	override int number(int value) 	// override setter
	{
		return 0; 
	}
	
	void method()
	{
		printNumber(this.number); // calls Base.number
	}
}