Skip to content

Commit e23b5a2

Browse files
committed
Merge pull request #84 from samuelgruetter/srewrite-tests-1
Explicit types for implicits in tests/untried
2 parents 1dfe656 + d51d08b commit e23b5a2

File tree

156 files changed

+71
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+71
-71
lines changed

tests/untried/neg/t5543.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
class C1 {
22
type T
3-
def this(x: T) { this() }
3+
def this(x: T) = { this() }
44
}
55

66
class C1a[T] {
7-
def this(x: T) { this() } // works, no error here
7+
def this(x: T) = { this() } // works, no error here
88
}
99

1010
class C2(x: Int) {
11-
def this(a: Int, b: Int = x) {
11+
def this(a: Int, b: Int = x) = {
1212
this(b)
1313
}
1414
}
1515

1616
class C3 {
1717
val x = 0
18-
def this(a: Int = x) { this() }
18+
def this(a: Int = x) = { this() }
1919
}

tests/untried/neg/t6666.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object F {
55
}
66

77
class COkay extends C(0) {
8-
def this(a: Any) {
8+
def this(a: Any) = {
99
this()
1010
def x = "".toString
1111
F.byname(x)

tests/untried/neg/t7605-deprecation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ abstract class Foo {
33
def baz
44
def boo(i: Int, l: Long)
55
def boz(i: Int, l: Long): Unit = {}
6-
def this(i: Int) { this() } // Don't complain here!
6+
def this(i: Int) = { this() } // Don't complain here!
77
def foz: Unit // Don't complain here!
88
}

tests/untried/pos/SI-7638.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait ArrayVectorOrder[@specialized(Int) A] extends Ordering[A] {
99
}
1010

1111
object vectorOrder {
12-
implicit def arrayOrder[@specialized(Int) A]() =
12+
implicit def arrayOrder[@specialized(Int) A](): miniboxing.tests.compile.ArrayVectorOrder[A] =
1313
/*
1414
* Before applying patch:
1515
*

tests/untried/pos/depmet_implicit_chaining_zw.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ trait ZipWith[N, S] {
77
}
88

99
object ZipWith {
10-
implicit def ZeroZipWith[S] = new ZipWith[Zero, S] {
10+
implicit def ZeroZipWith[S]: ZipWith[Zero,S]{type T = Stream[S]} = new ZipWith[Zero, S] {
1111
type T = Stream[S]
1212
}
1313

14-
implicit def SuccZipWith[N, S, R](implicit zWith : ZipWith[N, R]) = new ZipWith[Succ[N], S => R] {
14+
implicit def SuccZipWith[N, S, R](implicit zWith : ZipWith[N, R]): ZipWith[Succ[N],S => R]{type T = Stream[S] => zWith.T} = new ZipWith[Succ[N], S => R] {
1515
type T = Stream[S] => zWith.T // dependent types replace the associated types functionality
1616
}
1717

tests/untried/pos/depmet_implicit_norm_ret.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object Test{
33

44
// fallback, lower priority (overloading rules apply: pick alternative in subclass lowest in subtyping lattice)
55
class ZipWithDefault {
6-
implicit def ZeroZipWith[S] = new ZipWith[S] {
6+
implicit def ZeroZipWith[S]: Test.ZipWith[S]{type T = Stream[S]} = new ZipWith[S] {
77
type T = Stream[S]
88
}
99
}
@@ -12,7 +12,7 @@ object Test{
1212
// def apply[S: ZipWith](s : S) = ?[ZipWith[S]].zipWith(s) // TODO: bug return type should be inferred
1313
def apply[S](s : S)(implicit zw: ZipWith[S]): zw.T = zw.zipWith(s)
1414

15-
implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]) = new ZipWith[S => R] {
15+
implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]): Test.ZipWith[S => R]{type T = Stream[S] => zWith.T} = new ZipWith[S => R] {
1616
type T = Stream[S] => zWith.T // dependent types replace the associated types functionality
1717
}
1818
}

tests/untried/pos/depmet_implicit_oopsla_session.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ object Sessions {
1111
def run(p: Stop, dp: Stop): Unit = {}
1212
}
1313

14-
implicit def InDual[A, B](implicit sessionDIn: Session[B]) =
14+
implicit def InDual[A, B](implicit sessionDIn: Session[B]): Sessions.Session[Sessions.In[A,B]]{type Dual = Sessions.Out[A,sessionDIn.Dual]} =
1515
new Session[In[A, B]] {
1616
type Dual = Out[A, sessionDIn.Dual]
1717

1818
def run(p: In[A, B], dp: Dual): Unit =
1919
sessionDIn.run(p.func(dp.x), dp.y)
2020
}
2121

22-
implicit def OutDual[A, B](implicit sessionDOut: Session[B]) =
22+
implicit def OutDual[A, B](implicit sessionDOut: Session[B]): Sessions.Session[Sessions.Out[A,B]]{type Dual = Sessions.In[A,sessionDOut.Dual]} =
2323
new Session[Out[A, B]] {
2424
type Dual = In[A, sessionDOut.Dual]
2525

tests/untried/pos/depmet_implicit_oopsla_session_2.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Sessions {
3333
// CD is the dual of Cont
3434
// -------------------------------------------[InDual]
3535
// Out[Data, CD] is the dual of In[Data, Cont]
36-
implicit def InDual[Data, Cont](implicit cont: Session[Cont]) = new Session[In[Data, Cont]] {
36+
implicit def InDual[Data, Cont](implicit cont: Session[Cont]): Sessions.Session[Sessions.In[Data,Cont]]{type Dual = Sessions.Out[Data,cont.Dual]} = new Session[In[Data, Cont]] {
3737
type Dual = Out[Data, cont.Dual]
3838

3939
def run(self: Self, dual: Dual): Unit =
@@ -43,7 +43,7 @@ object Sessions {
4343
// CD is the dual of Cont
4444
// -------------------------------------------[OutDual]
4545
// In[Data, CD] is the dual of Out[Data, Cont]
46-
implicit def OutDual[Data, Cont](implicit cont: Session[Cont]) = new Session[Out[Data, Cont]] {
46+
implicit def OutDual[Data, Cont](implicit cont: Session[Cont]): Sessions.Session[Sessions.Out[Data,Cont]]{type Dual = Sessions.In[Data,cont.Dual]} = new Session[Out[Data, Cont]] {
4747
type Dual = In[Data, cont.Dual]
4848

4949
def run(self: Self, dual: Dual): Unit =

tests/untried/pos/depmet_implicit_oopsla_zipwith.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ trait ZipWith[N, S] {
99
def zipWith: N => S => T = n => f => manyApp(n)(continually(f))
1010
}
1111
object ZipWith {
12-
implicit def ZeroZipWith[S] = new ZipWith[Zero, S] {
12+
implicit def ZeroZipWith[S]: ZipWith[Zero,S]{type T = Stream[S]} = new ZipWith[Zero, S] {
1313
type T = Stream[S]
1414

1515
def manyApp = n => xs => xs
1616
}
1717

18-
implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]) =
18+
implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]): ZipWith[Succ[N],S => R]{type T = Stream[S] => zw.T; def zapp[A, B](xs: Stream[A => B],ys: Stream[A]): Stream[B]} =
1919
new ZipWith[Succ[N],S => R] {
2020
type T = Stream[S] => zw.T
2121

tests/untried/pos/implicits-new.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ object Test1579 {
3232
class Query[E](val value: E)
3333
class Invoker(q: Any) { val foo = null }
3434

35-
implicit def unwrap[C](q: Query[C]) = q.value
36-
implicit def invoker(q: Query[Column]) = new Invoker(q)
35+
implicit def unwrap[C](q: Query[C]): C = q.value
36+
implicit def invoker(q: Query[Column]): Test1579.Invoker = new Invoker(q)
3737

3838
val q = new Query(new Column)
3939
q.foo
@@ -45,9 +45,9 @@ object Test1625 {
4545
def unwrap() = x
4646
}
4747

48-
implicit def byName[A](x: =>A) = new Wrapped(x)
48+
implicit def byName[A](x: =>A): Test1625.Wrapped = new Wrapped(x)
4949

50-
implicit def byVal[A](x: A) = x
50+
implicit def byVal[A](x: A): A = x
5151

5252
def main(args: Array[String]) = {
5353

tests/untried/pos/implicits-old.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ object Test1579 {
2929
class Query[E](val value: E)
3030
class Invoker(q: Any) { val foo = null }
3131

32-
implicit def unwrap[C](q: Query[C]) = q.value
33-
implicit def invoker(q: Query[Column]) = new Invoker(q)
32+
implicit def unwrap[C](q: Query[C]): C = q.value
33+
implicit def invoker(q: Query[Column]): Test1579.Invoker = new Invoker(q)
3434

3535
val q = new Query(new Column)
3636
q.foo
@@ -42,9 +42,9 @@ object Test1625 {
4242
def unwrap() = x
4343
}
4444

45-
implicit def byName[A](x: =>A) = new Wrapped(x)
45+
implicit def byName[A](x: =>A): Test1625.Wrapped = new Wrapped(x)
4646

47-
implicit def byVal[A](x: A) = x
47+
implicit def byVal[A](x: A): A = x
4848

4949
def main(args: Array[String]) = {
5050

tests/untried/pos/presuperContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class B(x: Int)
66

77
class D {
88
class C(x: Int) extends B({val test: D = this; x}) {
9-
def this() {
9+
def this() = {
1010
this({val test: D = this; 1})
1111
}
1212
}

tests/untried/pos/t0438.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Foo {
2-
implicit def pair2fun2[A, B, C](f: (A, B) => C) =
2+
implicit def pair2fun2[A, B, C](f: (A, B) => C): ((A, B)) => C =
33
{p: (A, B) => f(p._1, p._2) }
44

55
def foo(f: ((Int, Int)) => Int) = f

tests/untried/pos/t0591.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Test {
22
def implicitly[T](implicit t : T) = t
33
implicit def perhaps[T](implicit t : T) : Option[T] = Some(t)
4-
implicit val hello = "Hello"
4+
implicit val hello: String = "Hello"
55
implicitly[String]
66
implicitly[Option[String]]
77
}

tests/untried/pos/t0786.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ object ImplicitProblem {
77
def eval: Int
88
}
99

10-
implicit def toRep0(n: Int) = new Rep[Int] {
10+
implicit def toRep0(n: Int): ImplicitProblem.Rep[Int] = new Rep[Int] {
1111
def eval = 0
1212
}
1313

14-
implicit def toRepN[T](n: M[T])(implicit f: T => Rep[T]) = new Rep[M[T]] {
14+
implicit def toRepN[T](n: M[T])(implicit f: T => Rep[T]): ImplicitProblem.Rep[ImplicitProblem.M[T]] = new Rep[M[T]] {
1515
def eval = f(nullval[T]).eval + 1
1616
}
1717

tests/untried/pos/t0851.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object test1 {
55
def apply(t : T) = (s:T2) => f(t,s)
66
def apply(p : (T,T2)) = f(p._1,p._2)
77
}
8-
implicit def g[T](f : (T,String) => String) = Foo(f)
8+
implicit def g[T](f : (T,String) => String): test.test1.Foo[T,String] = Foo(f)
99
def main(args : Array[String]) : Unit = {
1010
val f = (x:Int,s:String) => s + x
1111
println(f(1))

tests/untried/pos/t0872.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Main {
22
def main(args : Array[String]): Unit = {
33
val fn = (a : Int, str : String) => "a: " + a + ", str: " + str
4-
implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null)
4+
implicit def fx[T](f : (T,String) => String): T => String = (x:T) => f(x,null)
55
println(fn(1))
66
()
77
}

tests/untried/pos/t1147.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class App(arg: String) {
2-
@deprecated("..") def this() {
2+
@deprecated("..") def this() = {
33
this("foo")
44
}
55
}

tests/untried/pos/t1832.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ trait Cloning {
22
trait Foo
33
def fn(g: Any => Unit): Foo
44

5-
implicit def mkStar(i: Int) = new { def *(a: Foo): Foo = null }
5+
implicit def mkStar(i: Int): AnyRef{def *(a: Cloning.this.Foo): Cloning.this.Foo} = new { def *(a: Foo): Foo = null }
66

77
val pool = 4 * fn { case ghostSYMBOL: Int => ghostSYMBOL * 2 }
88
}

tests/untried/pos/t2060.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Test {
2424
def plus [I](op : Op[I]): Op[I] = op;
2525
}
2626

27-
implicit def iToRich(x : Double) =
27+
implicit def iToRich(x : Double): Test.Rich =
2828
new Rich(x);
2929

3030
// fails to compile

tests/untried/pos/t2421_delitedsl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trait DeliteDSL {
88
}
99

1010
case class DeliteInt(x: Int) extends Forcible[Int]
11-
implicit val forcibleInt = Forcible.factory(DeliteInt(_: Int))
11+
implicit val forcibleInt: DeliteDSL.this.<~<[Int,DeliteDSL.this.Forcible[Int]] = Forcible.factory(DeliteInt(_: Int))
1212

1313
import scala.collection.Traversable
1414
class DeliteCollection[T](val xs: Traversable[T]) {

tests/untried/pos/t2421b_pos.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Test {
77
def f(implicit aa: F[A]) = println(aa)
88

99
implicit def a : F[A] = new F[A]()
10-
implicit def b[X <: B] = new F[X]()
10+
implicit def b[X <: B]: Test.F[X] = new F[X]()
1111

1212
f
1313
}

tests/untried/pos/t2421c.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ object Test {
1010

1111
// generalised from t2421b to verify we check enough
1212
class G[X]
13-
implicit def g[X] = new G[X]()
14-
implicit def b[X <: B](implicit mx: G[X]) = new F[X]()
13+
implicit def g[X]: Test.G[X] = new G[X]()
14+
implicit def b[X <: B](implicit mx: G[X]): Test.F[X] = new F[X]()
1515

1616
f
1717
}

tests/untried/pos/t2782.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ object Test {
44
trait Foo[T]
55

66
// Haven't managed to repro without using a CanBuild or CanBuildFrom implicit parameter
7-
implicit def MapFoo[A, B, M[A, B] <: sc.Map[A,B]](implicit aFoo: Foo[A], bFoo: Foo[B], cb: sc.generic.CanBuild[(A, B), M[A, B]]) = new Foo[M[A,B]] {}
7+
implicit def MapFoo[A, B, M[A, B] <: sc.Map[A,B]](implicit aFoo: Foo[A], bFoo: Foo[B], cb: sc.generic.CanBuild[(A, B), M[A, B]]): Test.Foo[M[A,B]] = new Foo[M[A,B]] {}
88
implicit object Tuple2IntIntFoo extends Foo[(Int, Int)] // no difference if this line is uncommented
9-
implicit def Tuple2Foo[A, B] = new Foo[(A, B)] {} // nor this one
9+
implicit def Tuple2Foo[A, B]: Test.Foo[(A, B)] = new Foo[(A, B)] {} // nor this one
1010

1111
implicitly[Foo[(Int, Int)]]
1212
}

tests/untried/pos/t2913.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class RichA {
1010

1111
object Test {
1212

13-
implicit def AToRichA(a: A) = new RichA
13+
implicit def AToRichA(a: A): RichA = new RichA
1414

1515
val a = new A
1616
a.foo()
@@ -36,7 +36,7 @@ object test1 {
3636
def apply(t : T) = (s:T2) => f(t,s)
3737
def apply(p : (T,T2)) = f(p._1,p._2)
3838
}
39-
implicit def g[T](f : (T,String) => String) = Foo(f)
39+
implicit def g[T](f : (T,String) => String): test1.Foo[T,String] = Foo(f)
4040
def main(args : Array[String]) : Unit = {
4141
val f = (x:Int,s:String) => s + x
4242
println(f(1))
@@ -46,7 +46,7 @@ object test1 {
4646
object Main {
4747
def main(args : Array[String]): Unit = {
4848
val fn = (a : Int, str : String) => "a: " + a + ", str: " + str
49-
implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null)
49+
implicit def fx[T](f : (T,String) => String): T => String = (x:T) => f(x,null)
5050
println(fn(1))
5151
()
5252
}

tests/untried/pos/t3177.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ trait InvariantFunctor[F[_]] {
55
object InvariantFunctor {
66
import Endo._
77

8-
implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] {
8+
implicit val EndoInvariantFunctor: InvariantFunctor[Endo] = new InvariantFunctor[Endo] {
99
def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b)))
1010
}
1111

tests/untried/pos/t3373.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Entry(time: Long) {
55
object Test {
66
def extractTime(e: Entry) = e.getTime
77

8-
implicit val orderEntries = new Ordering[Entry] {
8+
implicit val orderEntries: Ordering[Entry] = new Ordering[Entry] {
99
def compare(first: Entry, second: Entry) = extractTime(first) compare extractTime(second)
1010
}
1111
}

tests/untried/pos/t3808.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Test {
22
def meh: Unit = {
33
trait TC[I]
4-
implicit val tci = new TC[Int]{}
4+
implicit val tci: TC[Int] = new TC[Int]{}
55

66
def baz[J : TC] : String = "meh"
77

tests/untried/pos/t3999/a_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ class Outside
44

55
package object bar {
66
class Val(b: Boolean)
7-
implicit def boolean2Val(b: Boolean) = new Val(b)
8-
implicit def boolean2Outside(b: Boolean) = new Outside
7+
implicit def boolean2Val(b: Boolean): foo.bar.package.Val = new Val(b)
8+
implicit def boolean2Outside(b: Boolean): foo.Outside = new Outside
99
}

tests/untried/pos/t4273.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class A {
2-
implicit def compareComparables[T](x: T)(implicit ord: Ordering[T]) = new ord.Ops(x)
2+
implicit def compareComparables[T](x: T)(implicit ord: Ordering[T]): ord.Ops = new ord.Ops(x)
33

44
class Bippy
5-
implicit val bippyOrdering = new Ordering[Bippy] { def compare(x: Bippy, y: Bippy) = util.Random.nextInt }
5+
implicit val bippyOrdering: Ordering[A.this.Bippy] = new Ordering[Bippy] { def compare(x: Bippy, y: Bippy) = util.Random.nextInt }
66

77
(new Bippy) < (new Bippy)
88
}

tests/untried/pos/t4457_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ object ImplicitConvAmbiguity2 {
66
class AA[A]
77
class BB[A]
88

9-
implicit def conv1(i: Float) = new NE[Float]
10-
implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException]
11-
implicit def conv4(op: AA[Float]) = new N[Float]
12-
implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar]
9+
implicit def conv1(i: Float): ImplicitConvAmbiguity2.NE[Float] = new NE[Float]
10+
implicit def conv3(op: AA[java.util.TooManyListenersException]): ImplicitConvAmbiguity2.N[java.util.TooManyListenersException] = new N[java.util.TooManyListenersException]
11+
implicit def conv4(op: AA[Float]): ImplicitConvAmbiguity2.N[Float] = new N[Float]
12+
implicit def conv5(e: BB[java.util.GregorianCalendar]): ImplicitConvAmbiguity2.N[java.util.GregorianCalendar] = new N[java.util.GregorianCalendar]
1313

1414
def aFunc[A](a: NE[A]) = new AA[A]
1515
def aFunc[A](a: NN[A]) = new BB[A]

0 commit comments

Comments
 (0)