Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fast-track -Xlint:override-nullary to warn in 2.13 & error in 3
- Loading branch information
Showing
31 changed files
with
186 additions
and
54 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
nullary-override-3a.scala:4: error: non-nullary method overrides nullary method | ||
def x: Int (defined in class A) | ||
class B extends A { override def x(): Int = 4 } | ||
^ | ||
nullary-override-3a.scala:16: error: non-nullary method overrides nullary method | ||
def x: String (defined in trait T1) | ||
class Mix12b extends T1 with T2 { override def x() = "12b" } | ||
^ | ||
nullary-override-3a.scala:19: error: non-nullary method overrides nullary method | ||
def x: String (defined in trait T1) | ||
class Mix21b extends T2 with T1 { override def x() = "21b" } | ||
^ | ||
3 errors |
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 @@ | ||
// scalac: -Werror -Wunused:nowarn -Xsource:3 | ||
// | ||
class A { def x: Int = 3 } | ||
class B extends A { override def x(): Int = 4 } | ||
|
||
|
||
trait T1 { def x: String = "1" } | ||
trait T2 { def x(): String = "2" } | ||
|
||
// without overrides you just get: error: class X inherits conflicting members: | ||
// def x: String (defined in trait T1) and | ||
// def x(): String (defined in trait T2) | ||
// (note: this can be resolved by declaring an `override` in class X.) | ||
|
||
// Mix12a in nullary-override-3b | ||
class Mix12b extends T1 with T2 { override def x() = "12b" } | ||
|
||
class Mix21a extends T2 with T1 { override def x = "21a" } // no warning :( | ||
class Mix21b extends T2 with T1 { override def x() = "21b" } | ||
|
||
import java.util.concurrent.atomic.{ AtomicMarkableReference => AMR } | ||
trait Ref1 { def getReference: String = "1" } | ||
trait Ref2 { def getReference(): String = "2" } | ||
|
||
// without overrides you just get: error: class X inherits conflicting members: | ||
// def getReference(): String (defined in class AtomicMarkableReference) and | ||
// def getReference: String (defined in trait Ref1) | ||
// (note: this can be resolved by declaring an `override` in class X.) | ||
|
||
class Mark1a extends AMR[String]("", false) with Ref1 { override def getReference = "1a" } | ||
class Mark1b extends AMR[String]("", false) with Ref1 { override def getReference() = "1b" } | ||
|
||
class Mark2a extends AMR[String]("", false) with Ref2 { override def getReference = "2a" } | ||
class Mark2b extends AMR[String]("", false) with Ref2 { override def getReference() = "2b" } | ||
|
||
class Mark12a extends AMR[String]("", false) with Ref1 with Ref2 { override def getReference = "12a" } | ||
class Mark12b extends AMR[String]("", false) with Ref1 with Ref2 { override def getReference() = "12b" } | ||
|
||
class Mark21a extends AMR[String]("", false) with Ref2 with Ref1 { override def getReference = "21a" } | ||
class Mark21c extends AMR[String]("", false) with Ref2 with Ref1 { override def getReference() = "21b" } |
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,12 @@ | ||
nullary-override-3b.scala:11: error: type mismatch; | ||
found : String("12a") | ||
required: Int | ||
class Mix12a extends T1 with T2 { override def x = "12a" } | ||
^ | ||
nullary-override-3b.scala:6: error: nullary method assumes an empty parameter list from the overridden definition | ||
class Q extends P { override def x: Int = 4 } | ||
^ | ||
nullary-override-3b.scala:11: error: nullary method assumes an empty parameter list from the overridden definition | ||
class Mix12a extends T1 with T2 { override def x = "12a" } | ||
^ | ||
3 errors |
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,12 @@ | ||
// scalac: -Werror -Wunused:nowarn -Xsource:3 | ||
// | ||
// P has parens | ||
class P { def x(): Int = 3 } | ||
// Q is questionable | ||
class Q extends P { override def x: Int = 4 } | ||
|
||
trait T1 { def x: Int = 1 } | ||
trait T2 { def x(): Int = 2 } | ||
|
||
class Mix12a extends T1 with T2 { override def x = "12a" } | ||
// the rest in nullary-override-3a |
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,9 +1,21 @@ | ||
nullary-override.scala:15: warning: nullary method assumes an empty parameter list from the overridden definition | ||
class Q extends P { override def x: Int = 4 } | ||
^ | ||
nullary-override.scala:36: warning: nullary method assumes an empty parameter list from the overridden definition | ||
class Mix12a extends T1 with T2 { override def x = "12a" } | ||
^ | ||
nullary-override.scala:4: warning: non-nullary method overrides nullary method | ||
class B extends A { override def x(): Int = 4 } | ||
^ | ||
nullary-override.scala:36: warning: non-nullary method overrides nullary method | ||
class Mix12a extends T1 with T2 { override def x = "12a" } | ||
^ | ||
nullary-override.scala:37: warning: non-nullary method overrides nullary method | ||
class Mix12b extends T1 with T2 { override def x() = "12b" } | ||
^ | ||
nullary-override.scala:40: warning: non-nullary method overrides nullary method | ||
class Mix21b extends T2 with T1 { override def x() = "21b" } | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
2 warnings | ||
6 warnings | ||
1 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
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,10 @@ | ||
// scalac: -Werror -Wunused:nowarn -Xsource:3 | ||
// | ||
class C extends java.lang.CharSequence { | ||
def charAt(x$1: Int): Char = ??? | ||
def length: Int = ??? | ||
def subSequence(x$1: Int, x$2: Int): CharSequence = ??? | ||
} | ||
|
||
// Welcome to the Happy J | ||
class J { override def toString = "Happy J" } |
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
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
Oops, something went wrong.