Use -Xlint for the warning:
$ scala -Xlint
Welcome to Scala version 2.11.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :pa
// Entering paste mode (ctrl-D to finish)
class Queue[+T](private val leading:T)
{
def enqueue[U >: T](x:U) = new Queue[U](leading:U)
}
class StrangeIntQueue(private val leading:Int) extends Queue[Int](leading)
{
override def enqueue[Int](x:Int) = {
println( math.sqrt(x) )
super.enqueue(x).asInstanceOf[Queue[Int]]
}
}
// Exiting paste mode, now interpreting.
<console>:15: error: type mismatch;
found : Int
required: Double
println( math.sqrt(x) )
^
<console>:14: warning: a type was inferred to be `Any`; this may indicate a programming error.
override def enqueue[Int](x:Int) = {
^
<console>:14: warning: type parameter Int defined in method enqueue shadows class Int defined in package scala. You may want to rename your type parameter, or possibly remove it.
override def enqueue[Int](x:Int) = {
^