Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6731 from WalterBright/fix17349
fix Issue 17349 - Covariant overrides should be allowed merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
213 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* REQUIRED_ARGS: -dw | ||
* PERMUTE_ARGS: | ||
* TEST_OUTPUT: | ||
--- | ||
compilable/fix17349.d(37): Deprecation: cannot implicitly override base class method `fix17349.E.foo` with `fix17349.F.foo`; add `override` attribute | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=17349 | ||
|
||
struct S { } | ||
|
||
class C { | ||
void bar(); | ||
void foo(void* p); | ||
void abc(Object); | ||
void def(S); | ||
} | ||
|
||
class D : C { | ||
override void bar() const; | ||
override void foo(const void*); | ||
override void abc(const Object); | ||
override void def(const S); | ||
} | ||
|
||
alias fp_t = void function(int*); | ||
@safe void abc(const int*); | ||
fp_t fp = &abc; | ||
|
||
|
||
class E { | ||
void foo(void*); | ||
} | ||
|
||
class F : E { | ||
void foo(const void*); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// https://issues.dlang.org/show_bug.cgi?id=16303 | ||
|
||
void yayf(void function(int*) fp); | ||
void yayd(void delegate(int*) dg); | ||
|
||
void bar() | ||
{ | ||
void function(const(int)* p) fp; | ||
yayf(fp); // should be good but produces error | ||
|
||
void delegate(const(int)* p) dg; | ||
yayd(dg); // should be good but produces error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
/* REQUIRED_ARGS: | ||
PERMUTE_ARGS: | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=16538 | ||
|
||
const(int) retConst1(); | ||
int retConst2(); | ||
auto retConst = [&retConst1, &retConst2]; | ||
|
||
const(int*) retConstPtr1(); | ||
const(int)* retConstPtr2(); | ||
auto retConstPtr = [&retConstPtr1, &retConstPtr2]; | ||
|
||
void constArray1(const(int)[1]); | ||
void constArray2(const(int[1])); | ||
auto constArray = [&constArray1, &constArray2]; | ||
|
||
const(int)[] retConstSlice1(); | ||
const(int[]) retConstSlice2(); | ||
auto retConstSlice = [&retConstSlice1, &retConstSlice2]; | ||
|
||
void constSlice1(const(int)[]); | ||
void constSlice2(const(int[])); | ||
auto constSlice = [&constSlice1, &constSlice2]; | ||
|
||
void ptrToConst1(const(int)*); | ||
void ptrToConst2(const(int*)); | ||
auto ptrToConst = [&ptrToConst1, &ptrToConst2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
/* | ||
TEST_OUTPUT: | ||
/* TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail16600.d(19): Error: fail16600.S.__ctor called with argument types (string) const matches both: | ||
fail_compilation/fail16600.d(13): fail16600.S.this(string) | ||
fail_compilation/fail16600.d(22): Error: fail16600.S.__ctor called with argument types (string) const matches both: | ||
fail_compilation/fail16600.d(16): fail16600.S.this(string _param_0) | ||
and: | ||
fail_compilation/fail16600.d(14): fail16600.S.this(string) immutable | ||
fail_compilation/fail16600.d(17): fail16600.S.this(string _param_0) immutable | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=16600 | ||
|
||
struct S | ||
{ | ||
this(string); | ||
this(string) immutable; | ||
int i; | ||
|
||
this(string) { i = 1; } | ||
this(string) immutable { i = 2; } | ||
} | ||
|
||
void main() | ||
{ | ||
auto a = const(S)("abc"); | ||
assert(a.i == 2); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* REQUIRED_ARGS: -de | ||
* TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail17354.d(13): Deprecation: cannot implicitly override base class method `object.Object.opEquals` with `fail17354.Foo.opEquals`; add `override` attribute | ||
fail_compilation/fail17354.d(18): Deprecation: cannot implicitly override base class method `object.Object.opEquals` with `fail17354.Bar.opEquals`; add `override` attribute | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=17354 | ||
|
||
final class Foo | ||
{ | ||
bool opEquals(const Object) const {return true;} | ||
} | ||
|
||
class Bar | ||
{ | ||
bool opEquals(const Object) const {return true;} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters