Skip to content

Explicit types for implicits in tests/untried #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/untried/neg/t5543.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
class C1 {
type T
def this(x: T) { this() }
def this(x: T) = { this() }
}

class C1a[T] {
def this(x: T) { this() } // works, no error here
def this(x: T) = { this() } // works, no error here
}

class C2(x: Int) {
def this(a: Int, b: Int = x) {
def this(a: Int, b: Int = x) = {
this(b)
}
}

class C3 {
val x = 0
def this(a: Int = x) { this() }
def this(a: Int = x) = { this() }
}
2 changes: 1 addition & 1 deletion tests/untried/neg/t6666.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object F {
}

class COkay extends C(0) {
def this(a: Any) {
def this(a: Any) = {
this()
def x = "".toString
F.byname(x)
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/neg/t7605-deprecation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ abstract class Foo {
def baz
def boo(i: Int, l: Long)
def boz(i: Int, l: Long): Unit = {}
def this(i: Int) { this() } // Don't complain here!
def this(i: Int) = { this() } // Don't complain here!
def foz: Unit // Don't complain here!
}
2 changes: 1 addition & 1 deletion tests/untried/pos/SI-7638.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait ArrayVectorOrder[@specialized(Int) A] extends Ordering[A] {
}

object vectorOrder {
implicit def arrayOrder[@specialized(Int) A]() =
implicit def arrayOrder[@specialized(Int) A](): miniboxing.tests.compile.ArrayVectorOrder[A] =
/*
* Before applying patch:
*
Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/depmet_implicit_chaining_zw.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ trait ZipWith[N, S] {
}

object ZipWith {
implicit def ZeroZipWith[S] = new ZipWith[Zero, S] {
implicit def ZeroZipWith[S]: ZipWith[Zero,S]{type T = Stream[S]} = new ZipWith[Zero, S] {
type T = Stream[S]
}

implicit def SuccZipWith[N, S, R](implicit zWith : ZipWith[N, R]) = new ZipWith[Succ[N], S => R] {
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] {
type T = Stream[S] => zWith.T // dependent types replace the associated types functionality
}

Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/depmet_implicit_norm_ret.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object Test{

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

implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]) = new ZipWith[S => R] {
implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]): Test.ZipWith[S => R]{type T = Stream[S] => zWith.T} = new ZipWith[S => R] {
type T = Stream[S] => zWith.T // dependent types replace the associated types functionality
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/depmet_implicit_oopsla_session.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ object Sessions {
def run(p: Stop, dp: Stop): Unit = {}
}

implicit def InDual[A, B](implicit sessionDIn: Session[B]) =
implicit def InDual[A, B](implicit sessionDIn: Session[B]): Sessions.Session[Sessions.In[A,B]]{type Dual = Sessions.Out[A,sessionDIn.Dual]} =
new Session[In[A, B]] {
type Dual = Out[A, sessionDIn.Dual]

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

implicit def OutDual[A, B](implicit sessionDOut: Session[B]) =
implicit def OutDual[A, B](implicit sessionDOut: Session[B]): Sessions.Session[Sessions.Out[A,B]]{type Dual = Sessions.In[A,sessionDOut.Dual]} =
new Session[Out[A, B]] {
type Dual = In[A, sessionDOut.Dual]

Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/depmet_implicit_oopsla_session_2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object Sessions {
// CD is the dual of Cont
// -------------------------------------------[InDual]
// Out[Data, CD] is the dual of In[Data, Cont]
implicit def InDual[Data, Cont](implicit cont: Session[Cont]) = new Session[In[Data, Cont]] {
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]] {
type Dual = Out[Data, cont.Dual]

def run(self: Self, dual: Dual): Unit =
Expand All @@ -43,7 +43,7 @@ object Sessions {
// CD is the dual of Cont
// -------------------------------------------[OutDual]
// In[Data, CD] is the dual of Out[Data, Cont]
implicit def OutDual[Data, Cont](implicit cont: Session[Cont]) = new Session[Out[Data, Cont]] {
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]] {
type Dual = In[Data, cont.Dual]

def run(self: Self, dual: Dual): Unit =
Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/depmet_implicit_oopsla_zipwith.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ trait ZipWith[N, S] {
def zipWith: N => S => T = n => f => manyApp(n)(continually(f))
}
object ZipWith {
implicit def ZeroZipWith[S] = new ZipWith[Zero, S] {
implicit def ZeroZipWith[S]: ZipWith[Zero,S]{type T = Stream[S]} = new ZipWith[Zero, S] {
type T = Stream[S]

def manyApp = n => xs => xs
}

implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]) =
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]} =
new ZipWith[Succ[N],S => R] {
type T = Stream[S] => zw.T

Expand Down
8 changes: 4 additions & 4 deletions tests/untried/pos/implicits-new.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,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]): Test1579.Invoker = new Invoker(q)

val q = new Query(new Column)
q.foo
Expand All @@ -45,9 +45,9 @@ object Test1625 {
def unwrap() = x
}

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

implicit def byVal[A](x: A) = x
implicit def byVal[A](x: A): A = x

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

Expand Down
8 changes: 4 additions & 4 deletions tests/untried/pos/implicits-old.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,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]): Test1579.Invoker = new Invoker(q)

val q = new Query(new Column)
q.foo
Expand All @@ -42,9 +42,9 @@ object Test1625 {
def unwrap() = x
}

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

implicit def byVal[A](x: A) = x
implicit def byVal[A](x: A): A = x

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

Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/presuperContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class B(x: Int)

class D {
class C(x: Int) extends B({val test: D = this; x}) {
def this() {
def this() = {
this({val test: D = this; 1})
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t0438.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Foo {
implicit def pair2fun2[A, B, C](f: (A, B) => C) =
implicit def pair2fun2[A, B, C](f: (A, B) => C): ((A, B)) => C =
{p: (A, B) => f(p._1, p._2) }

def foo(f: ((Int, Int)) => Int) = f
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t0591.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Test {
def implicitly[T](implicit t : T) = t
implicit def perhaps[T](implicit t : T) : Option[T] = Some(t)
implicit val hello = "Hello"
implicit val hello: String = "Hello"
implicitly[String]
implicitly[Option[String]]
}
4 changes: 2 additions & 2 deletions tests/untried/pos/t0786.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ object ImplicitProblem {
def eval: Int
}

implicit def toRep0(n: Int) = new Rep[Int] {
implicit def toRep0(n: Int): ImplicitProblem.Rep[Int] = new Rep[Int] {
def eval = 0
}

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

Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t0851.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object test1 {
def apply(t : T) = (s:T2) => f(t,s)
def apply(p : (T,T2)) = f(p._1,p._2)
}
implicit def g[T](f : (T,String) => String) = Foo(f)
implicit def g[T](f : (T,String) => String): test.test1.Foo[T,String] = Foo(f)
def main(args : Array[String]) : Unit = {
val f = (x:Int,s:String) => s + x
println(f(1))
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t0872.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Main {
def main(args : Array[String]): Unit = {
val fn = (a : Int, str : String) => "a: " + a + ", str: " + str
implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null)
implicit def fx[T](f : (T,String) => String): T => String = (x:T) => f(x,null)
println(fn(1))
()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t1147.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class App(arg: String) {
@deprecated("..") def this() {
@deprecated("..") def this() = {
this("foo")
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t1832.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ trait Cloning {
trait Foo
def fn(g: Any => Unit): Foo

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

val pool = 4 * fn { case ghostSYMBOL: Int => ghostSYMBOL * 2 }
}
2 changes: 1 addition & 1 deletion tests/untried/pos/t2060.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Test {
def plus [I](op : Op[I]): Op[I] = op;
}

implicit def iToRich(x : Double) =
implicit def iToRich(x : Double): Test.Rich =
new Rich(x);

// fails to compile
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t2421_delitedsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait DeliteDSL {
}

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

import scala.collection.Traversable
class DeliteCollection[T](val xs: Traversable[T]) {
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t2421b_pos.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Test {
def f(implicit aa: F[A]) = println(aa)

implicit def a : F[A] = new F[A]()
implicit def b[X <: B] = new F[X]()
implicit def b[X <: B]: Test.F[X] = new F[X]()

f
}
Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/t2421c.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ object Test {

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

f
}
4 changes: 2 additions & 2 deletions tests/untried/pos/t2782.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object Test {
trait Foo[T]

// Haven't managed to repro without using a CanBuild or CanBuildFrom implicit parameter
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]] {}
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]] {}
implicit object Tuple2IntIntFoo extends Foo[(Int, Int)] // no difference if this line is uncommented
implicit def Tuple2Foo[A, B] = new Foo[(A, B)] {} // nor this one
implicit def Tuple2Foo[A, B]: Test.Foo[(A, B)] = new Foo[(A, B)] {} // nor this one

implicitly[Foo[(Int, Int)]]
}
Expand Down
6 changes: 3 additions & 3 deletions tests/untried/pos/t2913.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RichA {

object Test {

implicit def AToRichA(a: A) = new RichA
implicit def AToRichA(a: A): RichA = new RichA

val a = new A
a.foo()
Expand All @@ -36,7 +36,7 @@ object test1 {
def apply(t : T) = (s:T2) => f(t,s)
def apply(p : (T,T2)) = f(p._1,p._2)
}
implicit def g[T](f : (T,String) => String) = Foo(f)
implicit def g[T](f : (T,String) => String): test1.Foo[T,String] = Foo(f)
def main(args : Array[String]) : Unit = {
val f = (x:Int,s:String) => s + x
println(f(1))
Expand All @@ -46,7 +46,7 @@ object test1 {
object Main {
def main(args : Array[String]): Unit = {
val fn = (a : Int, str : String) => "a: " + a + ", str: " + str
implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null)
implicit def fx[T](f : (T,String) => String): T => String = (x:T) => f(x,null)
println(fn(1))
()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t3177.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trait InvariantFunctor[F[_]] {
object InvariantFunctor {
import Endo._

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

Expand Down
2 changes: 1 addition & 1 deletion tests/untried/pos/t3373.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Entry(time: Long) {
object Test {
def extractTime(e: Entry) = e.getTime

implicit val orderEntries = new Ordering[Entry] {
implicit val orderEntries: Ordering[Entry] = new Ordering[Entry] {
def compare(first: Entry, second: Entry) = extractTime(first) compare extractTime(second)
}
}
2 changes: 1 addition & 1 deletion tests/untried/pos/t3808.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Test {
def meh: Unit = {
trait TC[I]
implicit val tci = new TC[Int]{}
implicit val tci: TC[Int] = new TC[Int]{}

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

Expand Down
4 changes: 2 additions & 2 deletions tests/untried/pos/t3999/a_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class Outside

package object bar {
class Val(b: Boolean)
implicit def boolean2Val(b: Boolean) = new Val(b)
implicit def boolean2Outside(b: Boolean) = new Outside
implicit def boolean2Val(b: Boolean): foo.bar.package.Val = new Val(b)
implicit def boolean2Outside(b: Boolean): foo.Outside = new Outside
}
4 changes: 2 additions & 2 deletions tests/untried/pos/t4273.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class A {
implicit def compareComparables[T](x: T)(implicit ord: Ordering[T]) = new ord.Ops(x)
implicit def compareComparables[T](x: T)(implicit ord: Ordering[T]): ord.Ops = new ord.Ops(x)

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

(new Bippy) < (new Bippy)
}
8 changes: 4 additions & 4 deletions tests/untried/pos/t4457_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ object ImplicitConvAmbiguity2 {
class AA[A]
class BB[A]

implicit def conv1(i: Float) = new NE[Float]
implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException]
implicit def conv4(op: AA[Float]) = new N[Float]
implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar]
implicit def conv1(i: Float): ImplicitConvAmbiguity2.NE[Float] = new NE[Float]
implicit def conv3(op: AA[java.util.TooManyListenersException]): ImplicitConvAmbiguity2.N[java.util.TooManyListenersException] = new N[java.util.TooManyListenersException]
implicit def conv4(op: AA[Float]): ImplicitConvAmbiguity2.N[Float] = new N[Float]
implicit def conv5(e: BB[java.util.GregorianCalendar]): ImplicitConvAmbiguity2.N[java.util.GregorianCalendar] = new N[java.util.GregorianCalendar]

def aFunc[A](a: NE[A]) = new AA[A]
def aFunc[A](a: NN[A]) = new BB[A]
Expand Down
Loading