diff --git a/test/async/jvm/toughtype.scala b/test/async/jvm/toughtype.scala index 939d0647e985..9587afa35f19 100644 --- a/test/async/jvm/toughtype.scala +++ b/test/async/jvm/toughtype.scala @@ -199,7 +199,7 @@ package scala.async.run.toughtype { } object FunDep { - implicit def `Something to do with List`[W, S, R](implicit funDep: FunDep[W, S, R]) = + implicit def `Something to do with List`[W, S, R](implicit funDep: FunDep[W, S, R]): FunDep[W,List[S],W] = new FunDep[W, List[S], W] { def method(w: W, l: List[S]) = async { val it = l.iterator diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala index 411a6333992f..dda7cfbb4e47 100644 --- a/test/files/jvm/future-spec/main.scala +++ b/test/files/jvm/future-spec/main.scala @@ -17,9 +17,10 @@ object Test { } trait Features { - implicit def implicitously = scala.language.implicitConversions - implicit def reflectively = scala.language.reflectiveCalls - implicit def postulously = scala.language.postfixOps + import languageFeature._ + implicit def implicitously: implicitConversions = scala.language.implicitConversions + implicit def reflectively: reflectiveCalls = scala.language.reflectiveCalls + implicit def postulously: postfixOps = scala.language.postfixOps } @@ -40,7 +41,9 @@ trait MinimalScalaTest extends Output with Features with Vigil { if (throwables.nonEmpty) println(buffer.toString) } - implicit def stringops(s: String) = new { + type Ops = AnyRef{def should[U](snippets: => U): U; def in[U](snippet: => U): scala.collection.mutable.IndexedSeq[_ >: Char with Throwable] with scala.collection.mutable.AbstractSeq[_ >: Char with Throwable] with scala.collection.mutable.Growable[Char with Throwable] with java.io.Serializable} + + implicit def stringops(s: String): Ops = new { def should[U](snippets: => U) = { bufferPrintln(s + " should:") @@ -62,7 +65,8 @@ trait MinimalScalaTest extends Output with Features with Vigil { } - implicit def objectops(obj: Any) = new { + type OOps = AnyRef{def mustBe(other: Any): Unit; def mustEqual(other: Any): Unit} + implicit def objectops(obj: Any): OOps = new { def mustBe(other: Any) = assert(obj == other, s"$obj is not $other") def mustEqual(other: Any) = mustBe(other) diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 3acf90e25db0..2e9430f729c4 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -87,6 +87,8 @@ scala> case class Bar(n: Int) class Bar scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) + ^ + warning: Implicit definition should have explicit type (inferred Bar) warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature` def foo2bar(foo: Foo): Bar diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index d8eafde41b16..3633582cb376 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -1055,7 +1055,7 @@ class ExecutionContextPrepare extends TestBase { delegate.reportFailure(t) } - implicit val ec = new PreparingExecutionContext + implicit val ec: ExecutionContext = new PreparingExecutionContext def testOnComplete(): Unit = once { done => diff --git a/test/files/neg/implicit-log.scala b/test/files/neg/implicit-log.scala index f77085e3c2af..7af20610f64d 100644 --- a/test/files/neg/implicit-log.scala +++ b/test/files/neg/implicit-log.scala @@ -37,8 +37,8 @@ object Test1579 { class Query[E](val value: E) class Invoker(q: Any) { val foo = null } - implicit def unwrap[C](q: Query[C]) = q.value - implicit def invoker(q: Query[Column]) = new Invoker(q) + implicit def unwrap[C](q: Query[C]): C = q.value + implicit def invoker(q: Query[Column]): Invoker = new Invoker(q) val q = new Query(new Column) q.foo @@ -50,9 +50,9 @@ object Test1625 { def unwrap() = x } - implicit def byName[A](x: => A) = new Wrapped(x) + implicit def byName[A](x: => A): Wrapped = new Wrapped(x) - implicit def byVal[A](x: A) = x + implicit def byVal[A](x: A): A = x def main(args: Array[String]) = { diff --git a/test/files/neg/implicits.check b/test/files/neg/implicits.check index 2eb03eb5f3db..6bcdf6c81285 100644 --- a/test/files/neg/implicits.check +++ b/test/files/neg/implicits.check @@ -16,4 +16,11 @@ implicits.scala:47: error: type mismatch; implicits.scala:59: error: could not find implicit value for parameter x: Nothing foo { ^ +implicits.scala:34: warning: Implicit definition should have explicit type (inferred T) + implicit def select[T](t: HSome[T,_]) = t.head + ^ +implicits.scala:35: warning: Implicit definition should have explicit type (inferred L) + implicit def selectTail[L](t: HSome[_,L]) = t.tail + ^ +2 warnings 4 errors diff --git a/test/files/neg/override-final-implicit.check b/test/files/neg/override-final-implicit.check index d46efa1acb52..d5e546078794 100644 --- a/test/files/neg/override-final-implicit.check +++ b/test/files/neg/override-final-implicit.check @@ -1,5 +1,9 @@ +override-final-implicit.scala:6: warning: Implicit definition should have explicit type (inferred Test.this.FooExtender) + override implicit def FooExtender(foo: String) = super.FooExtender(foo) + ^ override-final-implicit.scala:6: error: cannot override final member: final implicit def FooExtender(foo: String): Test.this.FooExtender (defined in class Implicits) override implicit def FooExtender(foo: String) = super.FooExtender(foo) ^ +1 warning 1 error diff --git a/test/files/neg/private-implicit-class.check b/test/files/neg/private-implicit-class.check index 31ddc9a023ab..1578f9102325 100644 --- a/test/files/neg/private-implicit-class.check +++ b/test/files/neg/private-implicit-class.check @@ -1,4 +1,8 @@ private-implicit-class.scala:6: error: method BarExtender in class ImplicitsPrivate cannot be accessed as a member of ImplicitsPrivate from class TestPrivate override implicit def BarExtender(bar: Int) = super.BarExtender(bar) // error ^ +private-implicit-class.scala:6: warning: Implicit definition should have explicit type + override implicit def BarExtender(bar: Int) = super.BarExtender(bar) // error + ^ +1 warning 1 error diff --git a/test/files/neg/t1038.scala b/test/files/neg/t1038.scala index 367022965b99..2cc45a190eea 100644 --- a/test/files/neg/t1038.scala +++ b/test/files/neg/t1038.scala @@ -4,5 +4,6 @@ object Y { val a = new X import a._ implicit val b : Int = 1 + @annotation.nowarn implicit val c = 2 } diff --git a/test/files/neg/t2206.check b/test/files/neg/t2206.check index 5ea5570f9a90..75c5e19c58e5 100644 --- a/test/files/neg/t2206.check +++ b/test/files/neg/t2206.check @@ -2,4 +2,8 @@ t2206.scala:10: error: value f is not a member of o.A Note: implicit method ax is not applicable here because it comes after the application point and it lacks an explicit result type a.f() ^ +t2206.scala:13: warning: Implicit definition should have explicit type (inferred o.AX) + implicit def ax(a: A) = new AX + ^ +1 warning 1 error diff --git a/test/files/neg/t2421b.check b/test/files/neg/t2421b.check index 7c714f1c9bd7..644395fc6a12 100644 --- a/test/files/neg/t2421b.check +++ b/test/files/neg/t2421b.check @@ -1,4 +1,8 @@ t2421b.scala:12: error: could not find implicit value for parameter aa: Test.F[Test.A] f ^ +t2421b.scala:10: warning: Implicit definition should have explicit type (inferred Test.F[X]) + implicit def b[X <: B] = new F[X]() + ^ +1 warning 1 error diff --git a/test/files/neg/t2866.scala b/test/files/neg/t2866.scala index 2f464593d30c..d80822349244 100644 --- a/test/files/neg/t2866.scala +++ b/test/files/neg/t2866.scala @@ -1,7 +1,7 @@ // for 2.7.x compatibility object A { - implicit val one = 1 + implicit val one: Int = 1 } object Test { diff --git a/test/files/neg/t3006.check b/test/files/neg/t3006.check index b8dea080a766..e2358b0f0dd9 100644 --- a/test/files/neg/t3006.check +++ b/test/files/neg/t3006.check @@ -3,4 +3,8 @@ t3006.scala:8: error: type mismatch; required: Int println(A(3) + "H") ^ +t3006.scala:6: warning: Implicit definition should have explicit type (inferred Test.Foo) + implicit def aToFoo(x: A) = new Foo(x); + ^ +1 warning 1 error diff --git a/test/files/neg/t3346c.check b/test/files/neg/t3346c.check index 10c96eeb6cdb..4b18680e493d 100644 --- a/test/files/neg/t3346c.check +++ b/test/files/neg/t3346c.check @@ -1,4 +1,4 @@ -t3346c.scala:60: error: value bar is not a member of Either[Int,String] +t3346c.scala:65: error: value bar is not a member of Either[Int,String] did you mean map? eii.bar ^ diff --git a/test/files/neg/t3346c.scala b/test/files/neg/t3346c.scala index 59584e0a6168..287c91bdf2ca 100644 --- a/test/files/neg/t3346c.scala +++ b/test/files/neg/t3346c.scala @@ -1,3 +1,5 @@ +import annotation._ + object Test extends App { // // An attempt to workaround scala/bug#2712, foiled by scala/bug#3346 @@ -32,15 +34,18 @@ object Test extends App { } + @nowarn implicit def ToTCValue[M[_], A](ma: M[A])(implicit M0: TC[M]) = new TCValue[M, A] { - implicit val M = M0 + implicit val M: TC[M] = M0 val self = ma } implicit def ToTCValueBin1[M[_, _], A, B](ma: M[A, B])(implicit M0: TC[({type λ[α]=M[A, α]})#λ]): TCValue[({type λ[α] = M[A, α]})#λ, B] = new TCValue[({type λ[α]=M[A, α]})#λ, B] { + @nowarn implicit val M = M0 val self = ma } implicit def ToTCValueBin2[M[_, _], A, B](ma: M[A, B])(implicit M0: TC[({type λ[α]=M[α, B]})#λ]): TCValue[({type λ[α]=M[α, B]})#λ, A] = new TCValue[({type λ[α]=M[α, B]})#λ, A] { + @nowarn implicit val M = M0 val self = ma } diff --git a/test/files/neg/t3346i.check b/test/files/neg/t3346i.check index b1b5a140e8f9..dafa0b861e24 100644 --- a/test/files/neg/t3346i.check +++ b/test/files/neg/t3346i.check @@ -4,4 +4,20 @@ t3346i.scala:28: error: value a is not a member of Test.A[T] t3346i.scala:29: error: value a is not a member of Test.A[Nothing] (new A[Nothing]).a ^ +t3346i.scala:16: warning: Implicit definition should have explicit type (inferred Implicit1[T]) + implicit def implicit1[T <: Intermediate[_, _]](implicit b: Implicit2[T]) = new Implicit1[T](b) + ^ +t3346i.scala:18: warning: Implicit definition should have explicit type (inferred Implicit2[T]) + implicit def implicit2alt1[T <: Intermediate[_ <: String, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +t3346i.scala:19: warning: Implicit definition should have explicit type (inferred Implicit2[T]) + implicit def implicit2alt2[T <: Intermediate[_ <: Double, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +t3346i.scala:21: warning: Implicit definition should have explicit type (inferred Implicit3[T]) + implicit def implicit3alt1[T <: Intermediate[_, _ <: Int]] = new Implicit3[T]() + ^ +t3346i.scala:22: warning: Implicit definition should have explicit type (inferred Implicit3[T]) + implicit def implicit3alt2[T <: Intermediate[_ <: Double, _ <: AnyRef],X] = new Implicit3[T]() + ^ +5 warnings 2 errors diff --git a/test/files/neg/t4271.check b/test/files/neg/t4271.check index 402a7b9b7acb..d89d07f420a7 100644 --- a/test/files/neg/t4271.check +++ b/test/files/neg/t4271.check @@ -8,4 +8,23 @@ t4271.scala:11: error: value -> is not a member of Int did you mean >>>? 3 -> 5 ^ +t4271.scala:3: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def Ensuring[A](x: A) = Donotuseme + ^ +t4271.scala:4: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def doubleWrapper(x: Int) = Donotuseme + ^ +t4271.scala:5: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def floatWrapper(x: Int) = Donotuseme + ^ +t4271.scala:6: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def intWrapper(x: Int) = Donotuseme + ^ +t4271.scala:7: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def longWrapper(x: Int) = Donotuseme + ^ +t4271.scala:8: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def ArrowAssoc[A](x: A) = Donotuseme + ^ +6 warnings 3 errors diff --git a/test/files/neg/t4457_1.check b/test/files/neg/t4457_1.check index a16bb1ff8b1b..4d65bc39c1e0 100644 --- a/test/files/neg/t4457_1.check +++ b/test/files/neg/t4457_1.check @@ -4,4 +4,20 @@ and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAm match argument types (Float) val x = aFunc(4F) ^ +t4457_1.scala:11: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NE[Float]) + implicit def conv1(i: Float) = new NE[Float] + ^ +t4457_1.scala:12: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.TooManyListenersException]) + implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] + ^ +t4457_1.scala:13: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[Float]) + implicit def conv4(op: AA[Float]) = new N[Float] + ^ +t4457_1.scala:14: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NZ[Float]) + implicit def conv7(i: Float) = new NZ[Float] + ^ +t4457_1.scala:15: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.GregorianCalendar]) + implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] + ^ +5 warnings 1 error diff --git a/test/files/neg/t4457_2.check b/test/files/neg/t4457_2.check index b1310f74ed50..d0be6d48ef38 100644 --- a/test/files/neg/t4457_2.check +++ b/test/files/neg/t4457_2.check @@ -10,4 +10,20 @@ and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAm match argument types (Float) bFunc(aFunc(4F)) ^ +t4457_2.scala:11: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NE[Float]) + implicit def conv1(i: Float) = new NE[Float] + ^ +t4457_2.scala:12: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.TooManyListenersException]) + implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] + ^ +t4457_2.scala:13: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[Float]) + implicit def conv4(op: AA[Float]) = new N[Float] + ^ +t4457_2.scala:14: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NZ[Float]) + implicit def conv7(i: Float) = new NZ[Float] + ^ +t4457_2.scala:15: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.GregorianCalendar]) + implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] + ^ +5 warnings 2 errors diff --git a/test/files/neg/t4568.check b/test/files/neg/t4568.check index 3582e24b188a..604948e41b47 100644 --- a/test/files/neg/t4568.check +++ b/test/files/neg/t4568.check @@ -1,4 +1,8 @@ t4568.scala:8: error: recursive method isSubListOf needs result type case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1))) ^ +t4568.scala:2: warning: Implicit definition should have explicit type (inferred SubList.SubListable[A]) + implicit def sublistable[A](x: List[A]) = new SubListable(x) + ^ +1 warning 1 error diff --git a/test/files/neg/t4889.check b/test/files/neg/t4889.check index 96e9b7528e67..e643dd1ffc05 100644 --- a/test/files/neg/t4889.check +++ b/test/files/neg/t4889.check @@ -1,4 +1,8 @@ t4889.scala:19: error: could not find implicit value for parameter ma1: t4889.MatrixAdder[Int,[S]t4889.SparseMatrix[S]] m1.foo ^ +t4889.scala:14: warning: Implicit definition should have explicit type (inferred t4889.MatrixAdder[S,R]) + implicit def adderImplicit[S, R[s] <: Matrix[s, R]] = new MatrixAdder[S, R] { + ^ +1 warning 1 error diff --git a/test/files/neg/t5728.check b/test/files/neg/t5728.check index 7a80af2af06d..72a0c0273005 100644 --- a/test/files/neg/t5728.check +++ b/test/files/neg/t5728.check @@ -1,4 +1,8 @@ t5728.scala:3: error: implicit classes must accept exactly one primary constructor parameter implicit class Foo ^ +t5728.scala:5: warning: Implicit definition should have explicit type (inferred Test.Foo) + implicit def Foo = new Foo + ^ +1 warning 1 error diff --git a/test/files/neg/t6436.check b/test/files/neg/t6436.check index 27f4466572e5..2d74aa8c2a78 100644 --- a/test/files/neg/t6436.check +++ b/test/files/neg/t6436.check @@ -7,4 +7,11 @@ Note that implicit conversions are not applicable because they are ambiguous: are possible conversion functions from StringContext to ?{def q: ?} println(q"a") ^ +t6436.scala:2: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo1(ctx: StringContext) = new { def q = ??? } + ^ +t6436.scala:3: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo2(ctx: StringContext) = new { def q = ??? } + ^ +2 warnings 1 error diff --git a/test/files/neg/t6436b.check b/test/files/neg/t6436b.check index be9b17a4e387..8e33d7bb134a 100644 --- a/test/files/neg/t6436b.check +++ b/test/files/neg/t6436b.check @@ -7,4 +7,11 @@ Note that implicit conversions are not applicable because they are ambiguous: are possible conversion functions from StringContext to ?{def q: ?} println(StringContext("a").q()) ^ +t6436b.scala:2: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo1(ctx: StringContext) = new { def q = ??? } + ^ +t6436b.scala:3: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo2(ctx: StringContext) = new { def q = ??? } + ^ +2 warnings 1 error diff --git a/test/files/neg/t6567.check b/test/files/neg/t6567.check index 5ae946a4c1ac..552f4cbd48df 100644 --- a/test/files/neg/t6567.check +++ b/test/files/neg/t6567.check @@ -1,3 +1,6 @@ +t6567.scala:8: warning: Implicit definition should have explicit type (inferred B) + implicit def a2b(a: A) = new B + ^ t6567.scala:10: warning: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply. Option[B](a) ^ @@ -6,5 +9,5 @@ t6567.scala:12: warning: Suspicious application of an implicit view (Test.this.a ^ warning: 1 feature warning; re-run with -feature for details error: No warnings can be incurred under -Werror. -3 warnings +4 warnings 1 error diff --git a/test/files/neg/t6667.check b/test/files/neg/t6667.check index 1fe4a15e593e..dfcad24c4645 100644 --- a/test/files/neg/t6667.check +++ b/test/files/neg/t6667.check @@ -10,4 +10,8 @@ t6667.scala:9: error: ambiguous implicit values: match expected type C implicitly[C] // ambiguity reported, rather than falling back to C.companion ^ +t6667.scala:3: warning: Implicit definition should have explicit type (inferred C) + implicit def companion = new C + ^ +1 warning 2 errors diff --git a/test/files/neg/t6667.scala b/test/files/neg/t6667.scala index fb857ebd3322..840921f3449d 100644 --- a/test/files/neg/t6667.scala +++ b/test/files/neg/t6667.scala @@ -4,7 +4,7 @@ object C { } object Test { - implicit val inScope1, inScope2 = new C + implicit val inScope1, inScope2: C = new C implicitly[C]: Unit // C.companion was used; whereas the ambiguity should abort the implicit search. implicitly[C] // ambiguity reported, rather than falling back to C.companion } diff --git a/test/files/neg/t692.check b/test/files/neg/t692.check index 670495f6467d..42e2a1b8f2c6 100644 --- a/test/files/neg/t692.check +++ b/test/files/neg/t692.check @@ -16,4 +16,8 @@ t692.scala:14: error: class Foo takes type parameters t692.scala:19: error: class Foo takes type parameters class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo; ^ +t692.scala:11: warning: Implicit definition should have explicit type (inferred test3.this.FooType) + implicit def typeOfFoo = FooType(); + ^ +1 warning 6 errors diff --git a/test/files/neg/t712.check b/test/files/neg/t712.check index fc8f7824f2c7..606e41f04d92 100644 --- a/test/files/neg/t712.check +++ b/test/files/neg/t712.check @@ -1,4 +1,11 @@ t712.scala:10: error: overloaded method coerce needs result type implicit def coerce(p : ParentImpl) = p.self; ^ +t712.scala:3: warning: Implicit definition should have explicit type (inferred A.this.Node) + implicit def coerce(n : NodeImpl) = n.self; + ^ +t712.scala:10: warning: Implicit definition should have explicit type + implicit def coerce(p : ParentImpl) = p.self; + ^ +2 warnings 1 error diff --git a/test/files/neg/t7131.check b/test/files/neg/t7131.check index c66f1b4f927c..86df78172b9c 100644 --- a/test/files/neg/t7131.check +++ b/test/files/neg/t7131.check @@ -4,4 +4,11 @@ t7131.scala:21: error: type mismatch; Note: implicit method convertToSimpleMappable is not applicable here because it comes after the application point and it lacks an explicit result type x.value.map(f) ^ +t7131.scala:28: warning: Implicit definition should have explicit type (inferred ObservableValue.TraversableMappable[T,Container]) + implicit def convertToTraversableMappable[T, Container[X] <: Traversable[X]](x: ObservableValue[Container[T]]) = + ^ +t7131.scala:43: warning: Implicit definition should have explicit type (inferred ObservableValue.NestedMappable[T,Container]) + implicit def convertToSimpleMappable[T, Container[X] <: ObservableValue.HasMap[X, Container]](x: ObservableValue[Container[T]]) = + ^ +2 warnings 1 error diff --git a/test/files/neg/t729.check b/test/files/neg/t729.check index 050772cf84b9..7680b2fdfa4b 100644 --- a/test/files/neg/t729.check +++ b/test/files/neg/t729.check @@ -3,4 +3,11 @@ t729.scala:20: error: type mismatch; required: ScalaParserAutoEdit.this.NodeImpl(in trait ScalaParserAutoEdit) val yyy : NodeImpl = link.from; ^ +t729.scala:3: warning: Implicit definition should have explicit type (inferred Parser.this.Node) + implicit def coerce(n : NodeImpl) = n.self; + ^ +t729.scala:14: warning: Implicit definition should have explicit type (inferred ScalaParserAutoEdit.this.Node) + implicit def coerce(node : NodeImpl) = node.self; + ^ +2 warnings 1 error diff --git a/test/files/neg/t8322.check b/test/files/neg/t8322.check index 6c3f9a5e53ce..bc56230cd385 100644 --- a/test/files/neg/t8322.check +++ b/test/files/neg/t8322.check @@ -13,4 +13,11 @@ t8322.scala:19: error: type mismatch; required: scala.util.Either[?,?] Right(0).right.flatMap(_ => new String()) ^ +t8322.scala:15: warning: Implicit definition should have explicit type (inferred Writes[Seq[E]]) + implicit def rw[E] = Writes[Seq[E]] { _ => "" } + ^ +t8322.scala:17: warning: Implicit definition should have explicit type + implicit def wr[E] = jw(implicitly, implicitly) + ^ +2 warnings 3 errors diff --git a/test/files/pos/t7212.scala b/test/files/pos/t7212.scala index 1c1a3f07a2c2..4b53c034ff1f 100644 --- a/test/files/pos/t7212.scala +++ b/test/files/pos/t7212.scala @@ -13,3 +13,14 @@ class C extends B { override def f: Option[String] = Some("goodbye, cruel world") override def remove(): Unit = println("removed! (not really)") } + +trait T { def f: Object } +class K extends T { def f = "" } +object K { + val k = new K + val s: Any = k.f +} + +trait U extends T { def f = "" } +trait V { var v: Any } +trait W extends V { var v = "" } diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala index 9fa8a7babd7d..7ef9d247e1ba 100644 --- a/test/files/run/Meter.scala +++ b/test/files/run/Meter.scala @@ -23,7 +23,7 @@ package a { def apply(x: Double): Meter = new Meter(x) - implicit val boxings = new BoxingConversions[Meter, Double] { + implicit val boxings: BoxingConversions[Meter, Double] = new BoxingConversions[Meter, Double] { def box(x: Double) = new Meter(x) def unbox(m: Meter) = m.underlying } @@ -35,7 +35,7 @@ package a { override def toString = unbox.toString+"ft" } object Foot { - implicit val boxings = new BoxingConversions[Foot, Double] { + implicit val boxings: BoxingConversions[Foot, Double] = new BoxingConversions[Foot, Double] { def box(x: Double) = new Foot(x) def unbox(m: Foot) = m.unbox } diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala index 8c15bbb6d30b..1f40dc5e7dbc 100644 --- a/test/files/run/MeterCaseClass.scala +++ b/test/files/run/MeterCaseClass.scala @@ -20,7 +20,7 @@ package a { private[a] trait MeterArg - implicit val boxings = new BoxingConversions[Meter, Double] { + implicit val boxings: BoxingConversions[Meter, Double] = new BoxingConversions[Meter, Double] { def box(x: Double) = new Meter(x) def unbox(m: Meter) = m.underlying } @@ -32,7 +32,7 @@ package a { override def toString = unbox.toString+"ft" } object Foot { - implicit val boxings = new BoxingConversions[Foot, Double] { + implicit val boxings: BoxingConversions[Foot, Double] = new BoxingConversions[Foot, Double] { def box(x: Double) = new Foot(x) def unbox(m: Foot) = m.unbox } diff --git a/test/files/run/idempotency-lazy-vals.scala b/test/files/run/idempotency-lazy-vals.scala index 8688add3e699..236e1516137c 100644 --- a/test/files/run/idempotency-lazy-vals.scala +++ b/test/files/run/idempotency-lazy-vals.scala @@ -7,7 +7,7 @@ object Test extends App { val lazee = reify { class C { lazy val x = 2 - implicit lazy val y = 3 + implicit lazy val y: Int = 3 } val c = new C() import c._ diff --git a/test/files/run/impconvtimes.scala b/test/files/run/impconvtimes.scala index 477a16a8903d..d377685a9c77 100644 --- a/test/files/run/impconvtimes.scala +++ b/test/files/run/impconvtimes.scala @@ -9,7 +9,7 @@ object Test { def *(newUnit: Unit) = Measure(scalar, newUnit) } - implicit def double2Measure(scalar: Double) = + implicit def double2Measure(scalar: Double): Measure = Measure(scalar, NoUnit) diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala index 5681a9d484dc..fbc8536c041b 100644 --- a/test/files/run/implicits.scala +++ b/test/files/run/implicits.scala @@ -2,7 +2,7 @@ import scala.language.implicitConversions object A { object B { - implicit def int2string(x: Int) = "["+x.toString+"]" + implicit def int2string(x: Int): String = "["+x.toString+"]" } } diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala index 46367cd1a307..a126bd813d46 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala @@ -1,6 +1,6 @@ import scala.language.experimental.macros object Test extends App { - implicit val x = 42 + implicit val x: Int = 42 def foo(implicit x: Int): Unit = macro Impls.foo foo } diff --git a/test/files/run/macro-implicit-decorator/Test_2.scala b/test/files/run/macro-implicit-decorator/Test_2.scala index bfcb57986997..88c60d91b09f 100644 --- a/test/files/run/macro-implicit-decorator/Test_2.scala +++ b/test/files/run/macro-implicit-decorator/Test_2.scala @@ -5,9 +5,9 @@ class CustomClass trait MyTC[A] object MyTC { - implicit val forInt = new MyTC[Int] {} - implicit def forList[A](implicit a: Derivation[MyTC[A]]) = new MyTC[List[A]] {} - implicit def forCustomClass(implicit a: Derivation[MyTC[List[Boolean]]]) = new MyTC[CustomClass] {} + implicit val forInt: MyTC[Int] = new MyTC[Int] {} + implicit def forList[A](implicit a: Derivation[MyTC[A]]): MyTC[List[A]] = new MyTC[List[A]] {} + implicit def forCustomClass(implicit a: Derivation[MyTC[List[Boolean]]]): MyTC[CustomClass] = new MyTC[CustomClass] {} } object Test extends App { diff --git a/test/files/run/reflection-implicit.scala b/test/files/run/reflection-implicit.scala index a6e939322ad5..1e104d1e5809 100644 --- a/test/files/run/reflection-implicit.scala +++ b/test/files/run/reflection-implicit.scala @@ -3,7 +3,7 @@ import scala.language.implicitConversions import scala.reflect.runtime.universe._ class C { - implicit val v = new C + implicit val v: C = new C implicit def d(x: C)(implicit c: C): Int = ??? implicit class X(val x: Int) } diff --git a/test/files/run/repl-class-based-implicit-import.check b/test/files/run/repl-class-based-implicit-import.check index 9ad75cba7540..85d97a78c1fd 100644 --- a/test/files/run/repl-class-based-implicit-import.check +++ b/test/files/run/repl-class-based-implicit-import.check @@ -2,7 +2,7 @@ scala> def showInt(implicit x: Int) = println(x) def showInt(implicit x: Int): Unit -scala> object IntHolder { implicit val myInt = 5 } +scala> object IntHolder { implicit val myInt: Int = 5 } object IntHolder scala> import IntHolder.myInt diff --git a/test/files/run/repl-class-based-implicit-import.scala b/test/files/run/repl-class-based-implicit-import.scala index 9153c8e08f7f..133c99969f66 100644 --- a/test/files/run/repl-class-based-implicit-import.scala +++ b/test/files/run/repl-class-based-implicit-import.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { def code = """ |def showInt(implicit x: Int) = println(x) - |object IntHolder { implicit val myInt = 5 } + |object IntHolder { implicit val myInt: Int = 5 } |import IntHolder.myInt |showInt |class A; showInt diff --git a/test/files/run/repl-no-imports-no-predef-power.check b/test/files/run/repl-no-imports-no-predef-power.check index 64c4b37b92e2..52140e1b5c2c 100644 --- a/test/files/run/repl-no-imports-no-predef-power.check +++ b/test/files/run/repl-no-imports-no-predef-power.check @@ -11,7 +11,6 @@ warning: 1 deprecation (since 2.11.0); for details, enable `:setting -deprecatio val res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature` val tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 64c4b37b92e2..52140e1b5c2c 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -11,7 +11,6 @@ warning: 1 deprecation (since 2.11.0); for details, enable `:setting -deprecatio val res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature` val tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/sip23-implicit-resolution.scala b/test/files/run/sip23-implicit-resolution.scala index 5d83f89c43b1..beef7ae73e9f 100644 --- a/test/files/run/sip23-implicit-resolution.scala +++ b/test/files/run/sip23-implicit-resolution.scala @@ -4,11 +4,11 @@ object Test extends App { def mkAssoc[K, V0](k: K, v0: V0): Assoc[k.type] { type V = V0 } = new Assoc[k.type] {type V = V0 ; val v = v0} def lookup[K](k: K)(implicit a: Assoc[k.type]): a.V = a.v - implicit def firstAssoc = mkAssoc(1, "Panda!") - implicit def secondAssoc = mkAssoc(2, "Kitty!") + implicit def firstAssoc: Assoc[1] { type V = String } = mkAssoc(1, "Panda!") + implicit def secondAssoc: Assoc[2] { type V = String } = mkAssoc(2, "Kitty!") - implicit def ageAssoc = mkAssoc("Age", 3) - implicit def nmAssoc = mkAssoc("Name", "Jane") + implicit def ageAssoc: Assoc["Age"] { type V = Int } = mkAssoc("Age", 3) + implicit def nmAssoc: Assoc["Name"] { type V = String } = mkAssoc("Name", "Jane") assert(lookup(1) == "Panda!") assert(lookup(2) == "Kitty!") diff --git a/test/files/run/t2316_run.scala b/test/files/run/t2316_run.scala index 19d326f57f1a..2a17886aea46 100644 --- a/test/files/run/t2316_run.scala +++ b/test/files/run/t2316_run.scala @@ -1,7 +1,7 @@ case class T1(source: String) object T1 { - implicit def T1FromT2(implicit t2: T2) = new T1(t2.source) + implicit def T1FromT2(implicit t2: T2): T1 = new T1(t2.source) } case class T2(source: String) @@ -10,7 +10,7 @@ object A { def requireT1(implicit t1: T1) = t1 object B1 { - implicit val t2_b1 = new T2("from B1") + implicit val t2_b1: T2 = new T2("from B1") requireT1 } diff --git a/test/files/run/t2514.scala b/test/files/run/t2514.scala index 0bf716e8bbf6..6a58c8f63c36 100644 --- a/test/files/run/t2514.scala +++ b/test/files/run/t2514.scala @@ -2,9 +2,8 @@ import scala.language.{ implicitConversions, postfixOps, reflectiveCalls } -object Test -{ - implicit def x[A](a: A) = new { def xx = a } +object Test { + implicit def x[A](a: A): AnyRef{def xx: A} = new { def xx = a } def main(args: Array[String]): Unit = { val r1 = 12 xx; diff --git a/test/files/run/t2866.scala b/test/files/run/t2866.scala index c1583e91ace9..7c65e3c406bd 100644 --- a/test/files/run/t2866.scala +++ b/test/files/run/t2866.scala @@ -1,7 +1,7 @@ // for 2.7.x compatibility object A { - implicit val one = 1 + implicit val one: Int = 1 } object Test extends App { diff --git a/test/files/run/t3346d.scala b/test/files/run/t3346d.scala index 118318dee67d..261028dea3a9 100644 --- a/test/files/run/t3346d.scala +++ b/test/files/run/t3346d.scala @@ -11,7 +11,7 @@ object Test extends App { def create(v: A): Basket[A,B] } - implicit val bf = new BasketFactory[Int,TARInt] { + implicit val bf: BasketFactory[Int,TARInt] = new BasketFactory[Int,TARInt] { def create(v: Int): Basket[Int,TARInt] = new Basket[Int, TARInt]{} } diff --git a/test/files/run/t3346e.scala b/test/files/run/t3346e.scala index 8f75eb97edd3..66bba85818f6 100644 --- a/test/files/run/t3346e.scala +++ b/test/files/run/t3346e.scala @@ -47,9 +47,9 @@ class FilterMapFixed[A, Repr <% IterableOps[A, Iterable, _]](a: Repr) { } object MyEnhancements { - implicit def toQS[Coll](a: Coll) = new QuickSort(a) - implicit def toFM[Coll](a: Coll) = new FilterMap(a) - implicit def toFM2[A, Repr <% IterableOps[A, Iterable, _]](a: Repr) = new FilterMapFixed(a) + implicit def toQS[Coll](a: Coll): QuickSort[Coll] = new QuickSort(a) + implicit def toFM[Coll](a: Coll): FilterMap[Coll] = new FilterMap(a) + implicit def toFM2[A, Repr <% IterableOps[A, Iterable, _]](a: Repr): FilterMapFixed[A,Repr] = new FilterMapFixed(a) } object Test extends App { diff --git a/test/files/run/t3346f.scala b/test/files/run/t3346f.scala index 4799ca2ca9a5..b2dc16de5bfd 100644 --- a/test/files/run/t3346f.scala +++ b/test/files/run/t3346f.scala @@ -4,11 +4,11 @@ import scala.language.reflectiveCalls object Test extends App { trait Foo[A] implicit def fooString: Foo[String] = null - implicit def value[A](implicit foo: Foo[A]) = 5 + implicit def value[A](implicit foo: Foo[A]): Int = 5 println(implicitly[Int]) - implicit def conversion[A](x: Int)(implicit foo: Foo[A]) = new { + implicit def conversion[A](x: Int)(implicit foo: Foo[A]): AnyRef{def aMethod: Int} = new { def aMethod = 5 } println(1.aMethod) diff --git a/test/files/run/t3346h.check b/test/files/run/t3346h.check deleted file mode 100644 index 587be6b4c3f9..000000000000 --- a/test/files/run/t3346h.check +++ /dev/null @@ -1 +0,0 @@ -x diff --git a/test/files/run/t3346h.scala b/test/files/run/t3346h.scala index 642b7cf58505..3e94e25df7ed 100644 --- a/test/files/run/t3346h.scala +++ b/test/files/run/t3346h.scala @@ -3,7 +3,7 @@ import scala.language.implicitConversions object Test extends App { trait Fundep[T, U] { def u(t: T): U } class C { def y = "x" } - implicit val FundepStringC = new Fundep[String, C]{ def u(t: String) = new C } + implicit val FundepStringC: Fundep[String,C] = new Fundep[String, C]{ def u(t: String) = new C } implicit def foo[T, U](x: T)(implicit y: Fundep[T, U]): U = y.u(x) - println("x".y) + assert("x".y == "x") } diff --git a/test/files/run/t3346j.scala b/test/files/run/t3346j.scala index 719d11819af4..bfacb6d0e17a 100644 --- a/test/files/run/t3346j.scala +++ b/test/files/run/t3346j.scala @@ -5,7 +5,7 @@ import scala.reflect.runtime.universe._ object Test extends App { class A[T] class B[T] - implicit def foo[T: TypeTag](a: A[T])(implicit b: B[T]) = new { def baz = typeOf[T] } + implicit def foo[T: TypeTag](a: A[T])(implicit b: B[T]): AnyRef{def baz: reflect.runtime.universe.Type} = new { def baz = typeOf[T] } implicit def bar[T <: Int]: B[T] = new B[T]() println(new A[Int]().baz) } diff --git a/test/files/run/t5080.scala b/test/files/run/t5080.scala index acb6167f4652..8d0d04fd60ec 100644 --- a/test/files/run/t5080.scala +++ b/test/files/run/t5080.scala @@ -11,7 +11,7 @@ object Test extends App { override def toString = value.toString; } - implicit def conversions(x: Value) = new { + implicit def conversions(x: Value): AnyRef { def toInt: Int } = new { def toInt = x match { case Num(n) => n diff --git a/test/files/run/t5276_2b.scala b/test/files/run/t5276_2b.scala index 9cc789ec22c8..eb3d744befa4 100644 --- a/test/files/run/t5276_2b.scala +++ b/test/files/run/t5276_2b.scala @@ -4,7 +4,7 @@ import scala.tools.reflect.Eval object Test extends App { reify { class C { - implicit lazy val x = 2 + implicit lazy val x: Int = 2 def y = implicitly[Int] } diff --git a/test/files/run/t5565.scala b/test/files/run/t5565.scala index 9ced87ca21a7..3c9ed24003af 100644 --- a/test/files/run/t5565.scala +++ b/test/files/run/t5565.scala @@ -1,7 +1,9 @@ +import scala.annotation.nowarn import scala.language.reflectiveCalls import scala.language.implicitConversions object Test extends App { + @nowarn // the inferred type includes the default arg, which can't be written explicitly implicit def doubleWithApproxEquals(d: Double) = new { def ~==(v: Double, margin: Double = 0.001): Boolean = math.abs(d - v) < margin @@ -10,3 +12,11 @@ object Test extends App { assert(math.abs(-4.0) ~== (4.0, 0.001)) assert(math.abs(-4.0) ~== 4.0) } +/* +was: +Exception in thread "main" java.lang.IllegalAccessError: tried to access field illegal_access_error_test_case$.reflParams$Cache2 from class illegal_access_error_test_case$delayedInit$body + at illegal_access_error_test_case$delayedInit$body.(illegal_access_error_test_case.scala:8) + at illegal_access_error_test_case$.(illegal_access_error_test_case.scala:1) + at illegal_access_error_test_case$.(illegal_access_error_test_case.scala) + at illegal_access_error_test_case.main(illegal_access_error_test_case.scala) + */ diff --git a/test/files/run/t6290.scala b/test/files/run/t6290.scala index 9d05db0d1885..4a5ac1cf4d14 100644 --- a/test/files/run/t6290.scala +++ b/test/files/run/t6290.scala @@ -1,4 +1,5 @@ object Test { - implicit val foo = language.dynamics + import languageFeature._ + implicit val foo: dynamics = language.dynamics def main(args: Array[String]): Unit = () } diff --git a/test/files/run/t6327.scala b/test/files/run/t6327.scala index 4a2f6c3ee88f..7ebba247b871 100644 --- a/test/files/run/t6327.scala +++ b/test/files/run/t6327.scala @@ -7,8 +7,8 @@ object Test extends App { case class R[+T](s: String) { def x() = println(s) } // Implicits in contention; StringR is nested to avoid ambiguity - object R { implicit val StringR = R[String]("A") } - implicit val Default = R[Any]("B") + object R { implicit val StringR: R[String] = R[String]("A") } + implicit val Default: R[Any] = R[Any]("B") class B() extends Dynamic { def selectDynamic[T](f: String)(implicit r: R[T]): Unit = r.x() diff --git a/test/files/run/t657.scala b/test/files/run/t657.scala index d7f882b4342a..882c9bf3fb71 100644 --- a/test/files/run/t657.scala +++ b/test/files/run/t657.scala @@ -4,7 +4,7 @@ import scala.language.{ implicitConversions } abstract class BaseList { type Node <: BaseNodeImpl - implicit def convertNode(ni : BaseNodeImpl) = ni.asInstanceOf[Node]; + implicit def convertNode(ni : BaseNodeImpl): Node = ni.asInstanceOf[Node]; abstract class BaseNodeImpl } abstract class LinkedList extends BaseList { @@ -33,7 +33,7 @@ trait Matcher extends PrecedenceParser { trait NodeImpl4 extends super.NodeImpl3 type Matchable <: Node with MatchableImpl0 - implicit def convertMatchable(m : MatchableImpl0) = m.asInstanceOf[Matchable] + implicit def convertMatchable(m : MatchableImpl0): Matchable = m.asInstanceOf[Matchable] trait MatchableImpl0 extends NodeImpl4 { override def chop : Node = { Console.println("passed"); super.chop; diff --git a/test/files/run/t8564.scala b/test/files/run/t8564.scala index 6d7d1178c4a0..6ffaa75938e2 100644 --- a/test/files/run/t8564.scala +++ b/test/files/run/t8564.scala @@ -13,8 +13,8 @@ object Test extends App { def lookup(k: String)(implicit assoc: Assoc[k.type]): assoc.V = assoc.value - implicit def nameAssoc = mkAssoc("Name", "Mary") - implicit def ageAssoc = mkAssoc("Age", 23) + implicit def nameAssoc: Assoc["Name"] { type V = String } = mkAssoc("Name", "Mary") + implicit def ageAssoc: Assoc["Age"] { type V = Int } = mkAssoc("Age", 23) assert((lookup("Name"): String) == "Mary") assert((lookup("Age"): Int) == 23) diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala index 38455f05eebb..6144fb30dba0 100644 --- a/test/files/run/tcpoly_parseridioms.scala +++ b/test/files/run/tcpoly_parseridioms.scala @@ -103,8 +103,8 @@ trait ParserIdioms extends Parsers with Idioms { // TODO: how can parserIdiom(curry2(_)) be omitted? def expr: Parser[Expr] = parserIdiomFun(curry2(Plus)) <| num <> num |> - implicit def curry2[s, t, u](fun: (s, t) => u)(a: s)(b: t) = fun(a, b) - implicit def curry3[r, s, t, u](fun: (r, s, t) => u)(a: r)(b: s)(c: t) = fun(a, b, c) + implicit def curry2[s, t, u](fun: (s, t) => u)(a: s)(b: t): u = fun(a, b) + implicit def curry3[r, s, t, u](fun: (r, s, t) => u)(a: r)(b: s)(c: t): u = fun(a, b, c) } object Test extends ParserIdioms with App { diff --git a/test/junit/scala/io/SourceTest.scala b/test/junit/scala/io/SourceTest.scala index 0c4a996d1c9f..593b990d0413 100644 --- a/test/junit/scala/io/SourceTest.scala +++ b/test/junit/scala/io/SourceTest.scala @@ -10,7 +10,7 @@ import java.io.{Console => _, _} class SourceTest { - private implicit val `our codec` = Codec.UTF8 + private implicit val `our codec`: Codec = Codec.UTF8 private val charSet = Codec.UTF8.charSet.name private def sampler = """ diff --git a/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala b/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala index c57ca039a144..0248aebdb990 100644 --- a/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala +++ b/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala @@ -10,11 +10,11 @@ class AbstractFileClassLoaderTest { import scala.reflect.io._ import scala.io.Source - import scala.io.Codec.UTF8 + import scala.io.Codec, Codec.UTF8 import scala.reflect.io.Streamable import java.net.{ URLClassLoader, URL } - implicit def `we love utf8` = UTF8 + implicit def `we love utf8`: Codec = UTF8 implicit class `abs file ops`(f: AbstractFile) { def writeContent(s: String): Unit = Streamable.closing(f.bufferedOutput)(os => os write s.getBytes(UTF8.charSet)) } diff --git a/test/macro-annot/run/scopes/scopes_2.scala b/test/macro-annot/run/scopes/scopes_2.scala index 451931c14ee8..783c729aef1f 100644 --- a/test/macro-annot/run/scopes/scopes_2.scala +++ b/test/macro-annot/run/scopes/scopes_2.scala @@ -2,7 +2,7 @@ object Test extends App { def assertEquals(a: Any, b: Any): Unit = { assert(a == b, s"$a != $b") } - implicit val x = 42 + implicit val x: Int = 42 @explorer object C // @Test def toplevel: Unit = diff --git a/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala b/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala index 5b06a35725be..adae13349733 100644 --- a/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala +++ b/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala @@ -31,8 +31,8 @@ trait Generators { } yield mutable.TreeMap(keys zip values: _*) } - implicit def arbRedBlackTree[A: Arbitrary: Ordering, B: Arbitrary] = Arbitrary(genRedBlackTree[A, B]) - implicit def arbTreeMap[A: Arbitrary: Ordering, B: Arbitrary] = Arbitrary(genTreeMap[A, B]) + implicit def arbRedBlackTree[A: Arbitrary: Ordering, B: Arbitrary]: Arbitrary[RB.Tree[A,B]] = Arbitrary(genRedBlackTree[A, B]) + implicit def arbTreeMap[A: Arbitrary: Ordering, B: Arbitrary]: Arbitrary[mutable.TreeMap[A,B]] = Arbitrary(genTreeMap[A, B]) } object RedBlackTreeProperties extends Properties("mutable.RedBlackTree") with Generators { @@ -218,7 +218,7 @@ object MutableTreeMapProjectionProperties extends Properties("mutable.TreeMapPro type K = String type V = Int - implicit val ord = implicitly[Ordering[K]] + private val ord = implicitly[Ordering[K]] def in(key: K, from: Option[K], until: Option[K]) = from.fold(true)(_ <= key) && until.fold(true)(_ > key) diff --git a/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala b/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala index 39a44ae453e7..68ee90462935 100644 --- a/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala +++ b/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala @@ -117,7 +117,7 @@ object MutableTreeSetProperties extends Properties("mutable.TreeSet") { object MutableTreeSetProjectionProperties extends Properties("mutable.TreeSetProjection") { type K = String - implicit val ord = implicitly[Ordering[K]] + private val ord = implicitly[Ordering[K]] def in(key: K, from: Option[K], until: Option[K]) = from.fold(true)(_ <= key) && until.fold(true)(_ > key) diff --git a/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala b/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala index 19032a2d0fb7..bc6e6089c231 100644 --- a/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala +++ b/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala @@ -267,8 +267,8 @@ trait ArbitraryTreesAndNames { def genTreeIsTypeWrapped(size: Int) = for(tit <- genTreeIsType(size)) yield TreeIsType(tit) - implicit val liftTreeIsTerm = Liftable[TreeIsTerm] { _.tree } - implicit val liftTreeIsType = Liftable[TreeIsType] { _.tree } + implicit val liftTreeIsTerm: Liftable[TreeIsTerm] = Liftable[TreeIsTerm] { _.tree } + implicit val liftTreeIsType: Liftable[TreeIsType] = Liftable[TreeIsType] { _.tree } implicit def treeIsTerm2tree(tit: TreeIsTerm): Tree = tit.tree implicit def treeIsType2tree(tit: TreeIsType): Tree = tit.tree diff --git a/test/scalacheck/treemap.scala b/test/scalacheck/treemap.scala index 83fb586b5192..1df3424c2064 100644 --- a/test/scalacheck/treemap.scala +++ b/test/scalacheck/treemap.scala @@ -12,7 +12,7 @@ object TreeMapTest extends Properties("TreeMap") { keys <- listOf(arbitrary[A]) values <- listOfN(keys.size, arbitrary[B]) } yield TreeMap(keys zip values: _*) - implicit def arbTreeMap[A : Arbitrary : Ordering, B : Arbitrary] = Arbitrary(genTreeMap[A, B]) + implicit def arbTreeMap[A : Arbitrary : Ordering, B : Arbitrary]: Arbitrary[TreeMap[A, B]] = Arbitrary(genTreeMap[A, B]) property("foreach/iterator consistency") = forAll { (subject: TreeMap[Int, String]) => val it = subject.iterator diff --git a/test/scaladoc/run/diagrams-base.check b/test/scaladoc/run/diagrams-base.check index 619c56180bb9..ec9c6d6a74f2 100644 --- a/test/scaladoc/run/diagrams-base.check +++ b/test/scaladoc/run/diagrams-base.check @@ -1 +1,10 @@ +newSource:10: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.T) + object E { implicit def eToT(e: E) = new T } + ^ +newSource:18: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.E) + object X { implicit def xToE(x: X) = new E} + ^ +newSource:21: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.E) + object Z { implicit def zToE(z: Z) = new E} + ^ Done. diff --git a/test/scaladoc/run/diagrams-filtering.check b/test/scaladoc/run/diagrams-filtering.check index 619c56180bb9..6f40b2c32793 100644 --- a/test/scaladoc/run/diagrams-filtering.check +++ b/test/scaladoc/run/diagrams-filtering.check @@ -1 +1,7 @@ +newSource:30: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.T) + implicit def eToT(e: E) = new T + ^ +newSource:31: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.A) + implicit def eToA(e: E) = new A { } + ^ Done. diff --git a/test/scaladoc/run/implicits-ambiguating.check b/test/scaladoc/run/implicits-ambiguating.check index 619c56180bb9..f716066eb126 100644 --- a/test/scaladoc/run/implicits-ambiguating.check +++ b/test/scaladoc/run/implicits-ambiguating.check @@ -1 +1,7 @@ +newSource:70: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.ambiguating.X[T]) + implicit def AtoX[T](a: A[T]) = new X[T] + ^ +newSource:71: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.ambiguating.Z[T]) + implicit def AtoZ[T](a: A[T]) = new Z[T] + ^ Done. diff --git a/test/scaladoc/run/implicits-base.check b/test/scaladoc/run/implicits-base.check index 619c56180bb9..e5f9afca6ebf 100644 --- a/test/scaladoc/run/implicits-base.check +++ b/test/scaladoc/run/implicits-base.check @@ -1 +1,19 @@ +newSource:36: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.EnrichedA[V]) + implicit def enrichA0[V](a: A[V]) = new EnrichedA(a) + ^ +newSource:37: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.NumericA[ZBUR]) + implicit def enrichA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) + ^ +newSource:38: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.IntA) + implicit def enrichA2(a: A[Int]) = new IntA(a) + ^ +newSource:39: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.GtColonDoubleA) + implicit def enrichA3(a: A[T] forSome { type T <: Double }) = new GtColonDoubleA(a) + ^ +newSource:42: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.MyNumericA[Z]) + implicit def enrichA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) + ^ +newSource:44: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.ManifestA[H] with scala.test.scaladoc.implicits.base.MyTraversableOps[H]) + implicit def enrichA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } + ^ Done. diff --git a/test/scaladoc/run/implicits-chaining.check b/test/scaladoc/run/implicits-chaining.check index 619c56180bb9..9cbfe46b4ac1 100644 --- a/test/scaladoc/run/implicits-chaining.check +++ b/test/scaladoc/run/implicits-chaining.check @@ -1 +1,16 @@ +newSource:22: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit1[T]) + implicit def implicit1[T <: Intermediate[_, _]](implicit b: Implicit2[T]) = new Implicit1[T](b) + ^ +newSource:24: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit2[T]) + implicit def implicit2alt1[T <: Intermediate[_ <: String, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +newSource:25: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit2[T]) + implicit def implicit2alt2[T <: Intermediate[_ <: Double, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +newSource:27: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit3[T]) + implicit def implicit3alt1[T <: Intermediate[_, _ <: Int]] = new Implicit3[T]() + ^ +newSource:28: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit3[T]) + implicit def implicit3alt2[T <: Intermediate[_ <: Double, _ <: AnyRef],X] = new Implicit3[T]() + ^ Done. diff --git a/test/scaladoc/run/implicits-known-type-classes.check b/test/scaladoc/run/implicits-known-type-classes.check index 619c56180bb9..225b60e6cfe3 100644 --- a/test/scaladoc/run/implicits-known-type-classes.check +++ b/test/scaladoc/run/implicits-known-type-classes.check @@ -1 +1,49 @@ +newSource:13: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Numeric[T]]) + implicit def convertNumeric [T: Numeric] (a: A[T]) = new B(implicitly[Numeric[T]]) + ^ +newSource:14: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Integral[T]]) + implicit def convertIntegral [T: Integral] (a: A[T]) = new B(implicitly[Integral[T]]) + ^ +newSource:15: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Fractional[T]]) + implicit def convertFractional [T: Fractional] (a: A[T]) = new B(implicitly[Fractional[T]]) + ^ +newSource:16: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Manifest[T]]) + implicit def convertManifest [T: Manifest] (a: A[T]) = new B(implicitly[Manifest[T]]) + ^ +newSource:17: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[reflect.ClassManifest[T]]) + implicit def convertClassManifest [T: ClassManifest] (a: A[T]) = new B(implicitly[ClassManifest[T]]) + ^ +newSource:18: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[OptManifest[T]]) + implicit def convertOptManifest [T: OptManifest] (a: A[T]) = new B(implicitly[OptManifest[T]]) + ^ +newSource:19: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.reflect.ClassTag[T]]) + implicit def convertClassTag [T: ClassTag] (a: A[T]) = new B(implicitly[ClassTag[T]]) + ^ +newSource:20: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[reflect.runtime.universe.TypeTag[T]]) + implicit def convertTypeTag [T: TypeTag] (a: A[T]) = new B(implicitly[TypeTag[T]]) + ^ +newSource:29: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.K[T]]) + implicit def convertK [T: K] (a: A[T]) = new B(implicitly[K[T]]) + ^ +newSource:30: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.L[T]]) + implicit def convertL [T: L] (a: A[T]) = new B(implicitly[L[T]]) + ^ +newSource:31: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.M[T]]) + implicit def convertM [T: M] (a: A[T]) = new B(implicitly[M[T]]) + ^ +newSource:32: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.N[T]]) + implicit def convertN [T: N] (a: A[T]) = new B(implicitly[N[T]]) + ^ +newSource:33: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.O[T]]) + implicit def convertO [T: O] (a: A[T]) = new B(implicitly[O[T]]) + ^ +newSource:34: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.P[T]]) + implicit def convertP [T: P] (a: A[T]) = new B(implicitly[P[T]]) + ^ +newSource:35: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.Q[T]]) + implicit def convertQ [T: Q] (a: A[T]) = new B(implicitly[Q[T]]) + ^ +newSource:36: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.R[T]]) + implicit def convertR [T: R] (a: A[T]) = new B(implicitly[R[T]]) + ^ Done. diff --git a/test/scaladoc/run/implicits-shadowing.check b/test/scaladoc/run/implicits-shadowing.check index 619c56180bb9..59ba86b25cef 100644 --- a/test/scaladoc/run/implicits-shadowing.check +++ b/test/scaladoc/run/implicits-shadowing.check @@ -1 +1,4 @@ +newSource:63: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.shadowing.Z[T]) + implicit def AtoZ[T](a: A[T]) = new Z[T] + ^ Done. diff --git a/test/scaladoc/run/implicits-var-exp.check b/test/scaladoc/run/implicits-var-exp.check index 619c56180bb9..9cc519cab9e0 100644 --- a/test/scaladoc/run/implicits-var-exp.check +++ b/test/scaladoc/run/implicits-var-exp.check @@ -1 +1,7 @@ +newSource:8: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.variable.expansion.C) + implicit def aToC(a: A) = new C + ^ +newSource:9: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.variable.expansion.E with scala.test.scaladoc.variable.expansion.F) + implicit def aToE(a: A) = new E with F + ^ Done. diff --git a/test/tasty/neg/src-2/TestCtxFns_fail.scala b/test/tasty/neg/src-2/TestCtxFns_fail.scala index 150ec4a209bc..c1db5e1d1585 100644 --- a/test/tasty/neg/src-2/TestCtxFns_fail.scala +++ b/test/tasty/neg/src-2/TestCtxFns_fail.scala @@ -9,7 +9,7 @@ object TestCtxFns { def puts[T](t: T): Unit = logs += t.toString } - implicit val ctx = new TestContext + implicit val ctx: TestContext = new TestContext def test1: Unit = { puts(23)(ctx)