Skip to content

Commit

Permalink
Merge pull request #10524 from lrytz/t12858
Browse files Browse the repository at this point in the history
Fix spurious "nullary overrides nilary" warning
  • Loading branch information
lrytz committed Sep 1, 2023
2 parents f7e30a6 + 96d74ac commit 80514f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ abstract class RefChecks extends Transform {
warnAdaptedNullaryOverride()
}
else if (member.paramLists.isEmpty) {
// NullaryOverrideAdapted is only added to symbols being compiled, so check for a mismatch
// if both symbols are mixed in from the classpath
if (!member.isStable && other.paramLists.nonEmpty && !exempted)
// Definitions that directly override get a parameter list and a `NullaryOverrideAdapted` attachment
// in Namers. Here we also warn when there's a mismatch between two mixed-in members.
if (!member.isStable && other.paramLists.nonEmpty && !exempted && !other.overrides.exists(javaDetermined))
warnAdaptedNullaryOverride()
}
else if (other.paramLists.isEmpty) {
Expand Down
3 changes: 3 additions & 0 deletions test/files/pos/t12858/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface A {
int f();
}
9 changes: 9 additions & 0 deletions test/files/pos/t12858/B.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// scalac: -Werror

trait B1 extends A { def f: Int }
trait C1 { def f = 2 }
class T1 extends B1 with C1

trait B2 extends A { def f: Int = 1}
trait C2 { self: B2 => override def f = 2 }
class T2 extends B2 with C2

0 comments on commit 80514f7

Please sign in to comment.