D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8318 - Cannot override a method with inferred return type
Summary: Cannot override a method with inferred return type
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
: 9784 10021 10195 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-06-29 12:57 UTC by Jacob Carlborg
Modified: 2023-02-11 04:54 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2012-06-29 12:57:04 UTC
The following code fails to compile:

class Foo {
    auto foo() {
        return "Foo.foo";
    }
}

class Bar : Foo {
    override auto foo() {
        return "Bar.foo";
    }
}

void main() {}

It doesn't matter if "override" is specified or not. The error message received is:

Error: function main.Bar.foo of type () overrides but is not covariant with main.Foo.foo of type ()
Comment 1 Andrej Mitrovic 2013-05-28 13:59:32 UTC
*** Issue 10195 has been marked as a duplicate of this issue. ***
Comment 2 Sebastian Graf 2013-05-28 14:01:45 UTC
*** Issue 10021 has been marked as a duplicate of this issue. ***
Comment 3 Kenji Hara 2013-07-15 22:05:18 UTC
*** Issue 9784 has been marked as a duplicate of this issue. ***
Comment 4 github-bugzilla 2013-09-07 22:47:42 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6c2da99b6a968a3d68a6feb841714b0c5189fa24
Better error message for currently unsupported issue 8318
Comment 5 yebblies 2013-11-26 07:58:20 UTC
Now says:

testx.d(8): Error: function testx.Bar.foo return type inference is not supported if may override base class function