File tree 3 files changed +32
-1
lines changed
compiler/src/dotty/tools/dotc/core 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -490,7 +490,9 @@ object Denotations {
490
490
* 4. The access boundary of sym2 is properly contained in the access
491
491
* boundary of sym1. For protected access, we count the enclosing
492
492
* package as access boundary.
493
- * 5. sym1 a method but sym2 is not.
493
+ * 5. sym1 is a method but sym2 is not.
494
+ * 6. sym1 is a non-polymorphic method but sym2 is a polymorphic method.
495
+ * (to be consistent with infoMeet, see #4819)
494
496
* The aim of these criteria is to give some disambiguation on access which
495
497
* - does not depend on textual order or other arbitrary choices
496
498
* - minimizes raising of doubleDef errors
@@ -505,6 +507,7 @@ object Denotations {
505
507
accessBoundary(sym2).isProperlyContainedIn(accessBoundary(sym1)) ||
506
508
sym2.is(Bridge ) && ! sym1.is(Bridge ) ||
507
509
sym1.is(Method ) && ! sym2.is(Method )) ||
510
+ sym1.info.isInstanceOf [MethodType ] && sym2.info.isInstanceOf [PolyType ] ||
508
511
sym1.info.isErroneous)
509
512
510
513
/** Sym preference provided types also override */
Original file line number Diff line number Diff line change
1
+ trait One [X ] {
2
+ def concat (suffix : Int ): X = ???
3
+ }
4
+
5
+ trait Two [Y <: Foo ] {
6
+ def concat [Dummy ](suffix : Int ): Y = ???
7
+ }
8
+
9
+ class Foo extends One [Foo ] with Two [Foo ] {
10
+ concat(0 ) // OK
11
+
12
+ // TODO: This does not typecheck because the polymorphic overload is masked
13
+ // (we merge the denotations for both overloads into one and always prefer
14
+ // MethodType to PolyType, instead we should return a MultiDenotation). See #4819.
15
+ concat[Int ](0 ) // error (that should actually not be an error)
16
+ }
Original file line number Diff line number Diff line change
1
+ trait One [X ] {
2
+ def concat (suffix : Int ): X = ???
3
+ }
4
+
5
+ trait Two [Y <: Foo ] {
6
+ def concat [Dummy ](suffix : Int ): Y = ???
7
+ }
8
+
9
+ class Foo extends One [Foo ] with Two [Foo ] {
10
+ concat(0 ) // OK
11
+ // See also tests/neg/i4819.scala
12
+ }
You can’t perform that action at this time.
0 commit comments