File tree 4 files changed +56
-0
lines changed
compiler/src/dotty/tools/dotc/typer
docs/docs/reference/other-new-features 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -954,6 +954,12 @@ class Namer { typer: Typer =>
954
954
else if (sym.isConstructor || sym.is(ModuleClass ) || sym.is(Bridge )) SKIP
955
955
else if (cls.derivesFrom(sym.owner) &&
956
956
(sym.owner == cls || ! sym.is(Deferred ))) i " is already a member of $cls"
957
+ else if (sym.is(Override ))
958
+ sym.allOverriddenSymbols.find(
959
+ other => cls.derivesFrom(other.owner) && ! other.is(Deferred )) match {
960
+ case Some (other) => i " overrides ${other.showLocated}, which is already a member of $cls"
961
+ case None => " "
962
+ }
957
963
else " "
958
964
}
959
965
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ of one of the following forms:
59
59
A member is _ eligible_ if all of the following holds:
60
60
61
61
- its owner is not a base class of the class(* ) containing the export clause,
62
+ - the member does not override a concrete definition that has as owner
63
+ a base class of the class containing the export clause.
62
64
- it is accessible at the export clause,
63
65
- it is not a constructor, nor the (synthetic) class part of an object,
64
66
- it is a given instance (or an old-style ` implicit ` value)
Original file line number Diff line number Diff line change
1
+ object Test1 {
2
+ class A {
3
+ override def toString : String = " A"
4
+ }
5
+ class B (a : A ) {
6
+ export a .toString // error: no eligible member toString at B.this.a
7
+ }
8
+ }
9
+
10
+ object Test extends App {
11
+ trait T {
12
+ def foo : Int = 1
13
+ def bar : Int
14
+ }
15
+ class A extends T {
16
+ override def foo = 2
17
+ override def bar = 2
18
+ }
19
+ class B (a : A ) extends T {
20
+ export a .foo // error: no eligible member foo at B.this.a
21
+ export a .bar // OK
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ object Test1 {
2
+ class A {
3
+ override def toString : String = " A"
4
+ }
5
+ class B (a : A ) {
6
+ export a ._ // OK
7
+ }
8
+ }
9
+
10
+ object Test extends App {
11
+ trait T {
12
+ def foo : Int = 1
13
+ def bar : Int
14
+ }
15
+ class A extends T {
16
+ override def foo = 2
17
+ override def bar = 2
18
+ }
19
+ class B (a : A ) extends T {
20
+ export a ._
21
+ }
22
+ val b = B (A ())
23
+ assert(b.foo == 1 )
24
+ assert(b.bar == 2 )
25
+ }
You can’t perform that action at this time.
0 commit comments