You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scalac 2.11.6 compiler gives useful warnings about unrelated types comparsion for expression, method, and functions.
scalac 2.11.7 doesn't give warning for functions.
caseclassA(x: String)
objectApp {
// No warning with 2.11.7valfunc1= (x: A) ⇒ { x !="x" }
// No warning with 2.11.7valfunc2= (x: A) ⇒ { x !="x" }:Boolean// No warning with 2.11.7valfunc3:Function1[A, Boolean] = (x) ⇒ { x !="x" }
// Warning in method `apply` appearedvalfunc4=newFunction1[A, Boolean] {
defapply(x: A):Boolean= { x !="x" }
}
// Warning appeareddefmethod(x: A):Boolean= { x !="x" }
defmain(args: Array[String]) {
// Warning appearedA("x") !="x"// No warning with 2.11.7valfunc4:Function1[A, Boolean] = (x) ⇒ { x !="x" }
// No warning with 2.11.7List(A("x")).foreach((item: A) ⇒ item !="x")
}
}
Output of the scalac 2.11.7 and 2.12.0-M3 are the same:
[warn] C:\...\App.scala:18: comparing values of types abc.A and String using `!=' will always yield true
[warn] def apply(x: A): Boolean = { x != "x" }
[warn] ^
[warn] C:\...\App.scala:22: comparing values of types abc.A and String using `!=' will always yield true
[warn] def method(x: A): Boolean = { x != "x" }
[warn] ^
[warn] C:\...\App.scala:27: comparing values of types abc.A and String using `!=' will always yield true
[warn] A("x") != "x"
[warn] ^
[warn] three warnings found
Output of the scalac 2.11.6 (desired behaviour)
C:\...\App.scala:8: comparing values of types abc.A and String using `!=' will always yield true
val func1 = (x: A) ? { x != "x" }
^
C:\...\App.scala:11: comparing values of types abc.A and String using `!=' will always yield true
val func2 = (x: A) ? { x != "x" }: Boolean
^
C:\...\App.scala:14: comparing values of types abc.A and String using `!=' will always yield true
val func3: Function1[A, Boolean] = (x) ? { x != "x" }
^
C:\...\App.scala:18: comparing values of types abc.A and String using `!=' will always yield true
def apply(x: A): Boolean = { x != "x" }
^
C:\Users\easy\sandbox\sbt-hide-warnings\src\main\scala\icm\App.scala:22: comparing values of types abc.A and String using `!=' will always yield true
def method(x: A): Boolean = { x != "x" }
^
C:\Users\easy\sandbox\sbt-hide-warnings\src\main\scala\icm\App.scala:27: comparing values of types abc.A and String using `!=' will always yield true
A("x") != "x"
^
C:\Users\easy\sandbox\sbt-hide-warnings\src\main\scala\icm\App.scala:30: comparing values of types abc.A and String using `!=' will always yield true
val func4: Function1[A, Boolean] = (x) ? { x != "x" }
^
C:\..\App.scala:33: comparing values of types abc.A and String using `!=' will always yield true
List(A("x")).foreach((item: A) ? item != "x")
^
8 warnings found
The text was updated successfully, but these errors were encountered:
scalac 2.11.6 compiler gives useful warnings about unrelated types comparsion for expression, method, and functions.
scalac 2.11.7 doesn't give warning for functions.
Output of the scalac 2.11.7 and 2.12.0-M3 are the same:
Output of the scalac 2.11.6 (desired behaviour)
The text was updated successfully, but these errors were encountered: