-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathscala2-t11681.scala
109 lines (85 loc) · 2.39 KB
/
scala2-t11681.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//> using options -Wunused:params
import Answers._
trait InterFace {
/** Call something. */
def call(a: Int, b: String, c: Double): Int
}
trait BadAPI extends InterFace {
private def f(a: Int,
b: String, // warn
c: Double): Int = {
println(c)
a
}
@deprecated("no warn in deprecated API", since="yesterday")
def g(a: Int,
b: String, // OK
c: Double): Int = {
println(c)
a
}
override def call(a: Int,
b: String, // no warn (override)
c: Double): Int = {
println(c)
a
}
def meth(x: Int) = x
override def equals(other: Any): Boolean = true // OK
def i(implicit s: String) = answer // warn now
/*
def future(x: Int): Int = {
val y = 42
val x = y // maybe option to warn only if shadowed
x
}
*/
}
// mustn't alter warnings in super
trait PoorClient extends BadAPI {
override def meth(x: Int) = ??? // OK
}
class Unusing(u: Int) { // warn
def f = ???
}
class Valuing(val u: Int) // OK
class Revaluing(u: Int) { def f = u } // OK
case class CaseyKasem(k: Int) // OK
case class CaseyAtTheBat(k: Int)(s: String) // warn unused s
trait Ignorance {
def f(readResolve: Int) = answer // warn now
}
class Reusing(u: Int) extends Unusing(u) // OK
// TODO: check
// class Main {
// def main(args: Array[String]): Unit = println("hello, args") // OK
// }
trait Unimplementation {
def f(u: Int): Int = ??? // OK
}
trait DumbStuff {
def f(implicit dummy: DummyImplicit) = answer // ok
def g(dummy: DummyImplicit) = answer // warn now
}
trait Proofs {
def f[A, B](implicit ev: A =:= B) = answer // ok
def g[A, B](implicit ev: A <:< B) = answer // ok
def f2[A, B](ev: A =:= B) = answer // warn now
def g2[A, B](ev: A <:< B) = answer // warn now
}
trait Anonymous {
def f = (i: Int) => answer // warn now
def f1 = (_: Int) => answer // OK
def f2: Int => Int = _ + 1 // OK
def g = for (i <- List(1)) yield answer // no warn (that is a patvar)
}
trait Context[A]
trait Implicits {
def f[A](implicit ctx: Context[A]) = answer // no warn after all; previously, warn implicit param even though marker
def g[A: Context] = answer // no warn bound that is marker only
}
class Bound[A: Context] // no warn bound that is marker only
object Answers {
def answer: Int = 42
}
val a$1 = 2