mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Fix hidden base constructor supplemental message (#21069)
Fixes #21068. Also say base class *constructor* in supplemental message.
This commit is contained in:
parent
c4d45a1a49
commit
e896b5c98d
3 changed files with 38 additions and 6 deletions
|
@ -1835,10 +1835,15 @@ FuncDeclaration resolveFuncCall(Loc loc, Scope* sc, Dsymbol s,
|
||||||
functionResolve(mErr, baseFunction, loc, sc, tiargs, baseClass.type, argumentList);
|
functionResolve(mErr, baseFunction, loc, sc, tiargs, baseClass.type, argumentList);
|
||||||
if (mErr.last > MATCH.nomatch && mErr.lastf)
|
if (mErr.last > MATCH.nomatch && mErr.lastf)
|
||||||
{
|
{
|
||||||
errorSupplemental(loc, "%s `%s` hides base class function `%s`",
|
errorSupplemental(loc, "Note: %s `%s` hides base class %s `%s`",
|
||||||
fd.kind, fd.toPrettyChars(), mErr.lastf.toPrettyChars());
|
fd.kind, fd.toPrettyChars(),
|
||||||
errorSupplemental(loc, "add `alias %s = %s` to `%s`'s body to merge the overload sets",
|
mErr.lastf.kind, mErr.lastf.toPrettyChars());
|
||||||
fd.toChars(), mErr.lastf.toPrettyChars(), tthis.toChars());
|
|
||||||
|
if (!fd.isCtorDeclaration)
|
||||||
|
{
|
||||||
|
errorSupplemental(loc, "Add `alias %s = %s;` to `%s`'s body to merge the overload sets",
|
||||||
|
fd.toChars(), mErr.lastf.toPrettyChars(), tthis.toChars());
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/diag23384.d(28): Error: function `diag23384.Derived.fun(B b)` is not callable using argument types `(A)`
|
fail_compilation/diag23384.d(28): Error: function `diag23384.Derived.fun(B b)` is not callable using argument types `(A)`
|
||||||
fail_compilation/diag23384.d(28): function `diag23384.Derived.fun` hides base class function `diag23384.Base.fun`
|
fail_compilation/diag23384.d(28): Note: function `diag23384.Derived.fun` hides base class function `diag23384.Base.fun`
|
||||||
fail_compilation/diag23384.d(28): add `alias fun = diag23384.Base.fun` to `diag23384.Derived`'s body to merge the overload sets
|
fail_compilation/diag23384.d(28): Add `alias fun = diag23384.Base.fun;` to `diag23384.Derived`'s body to merge the overload sets
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
27
compiler/test/fail_compilation/hidden_ctor.d
Normal file
27
compiler/test/fail_compilation/hidden_ctor.d
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
TEST_OUTPUT:
|
||||||
|
---
|
||||||
|
fail_compilation/hidden_ctor.d(25): Error: constructor `hidden_ctor.B.this(string s)` is not callable using argument types `()`
|
||||||
|
fail_compilation/hidden_ctor.d(25): Note: constructor `hidden_ctor.B.this` hides base class constructor `hidden_ctor.A.this`
|
||||||
|
---
|
||||||
|
*/
|
||||||
|
|
||||||
|
class A {
|
||||||
|
int a;
|
||||||
|
|
||||||
|
this() {
|
||||||
|
this.a = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class B : A {
|
||||||
|
string b;
|
||||||
|
|
||||||
|
this(string s) {
|
||||||
|
super();
|
||||||
|
this.b = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void main() {
|
||||||
|
auto b = new B();
|
||||||
|
b = new B("Hi, Mom!");
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue