D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3676 - shared function override
Summary: shared function override
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-05 06:26 UTC by Masahiro Nakagawa
Modified: 2015-06-09 01:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Masahiro Nakagawa 2010-01-05 06:26:07 UTC
class Sample
{
    void method() {}
    shared void method() {}
}

class Sample2 : Sample
{
    override void method() {}
    override shared void method() {} // Line 10
}

2.037 succeeds in compiling this code, but 2.038 and 2.039 fail.
2.039 outputs following error message:

 foo.d(10): Error: function foo.Sample2.method of type shared void()
 overrides but is not covariant with foo.Sample2.method of type void()

For that matter, following code is minimum sample which same error occurs.

class Sample
{
    void method() {}
}

class Sample2 : Sample
{
    shared void method() {}
}
Comment 1 Walter Bright 2010-02-12 23:03:43 UTC
The first example compiles correctly with dmd 2.041.

The second example correctly fails, because shared cannot override an unshared method.