diff options
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/fun_undo_eta.scala | 10 | ||||
-rw-r--r-- | test/files/pos/sammy_ctor_arg.scala | 4 | ||||
-rw-r--r-- | test/files/pos/sammy_exist.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_implicit.scala | 11 | ||||
-rw-r--r-- | test/files/pos/sammy_infer_argtype_subtypes.scala | 6 | ||||
-rw-r--r-- | test/files/pos/sammy_inferargs.scala | 6 | ||||
-rw-r--r-- | test/files/pos/sammy_overload.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_overload.scala | 27 | ||||
-rw-r--r-- | test/files/pos/sammy_override.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_poly.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_poly.scala | 13 | ||||
-rw-r--r-- | test/files/pos/sammy_scope.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_scope.scala | 4 | ||||
-rw-r--r-- | test/files/pos/sammy_single.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_twice.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t4365/a_1.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t4365/b_1.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t8310.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8429.scala | 7 | ||||
-rw-r--r-- | test/files/pos/t9449.scala | 19 | ||||
-rw-r--r-- | test/files/pos/virtpatmat_exist1.scala | 3 |
21 files changed, 104 insertions, 18 deletions
diff --git a/test/files/pos/fun_undo_eta.scala b/test/files/pos/fun_undo_eta.scala new file mode 100644 index 0000000000..466b0e2629 --- /dev/null +++ b/test/files/pos/fun_undo_eta.scala @@ -0,0 +1,10 @@ +class Test { + def m(i: Int) = i + + def expectWild[A](f: A) = ??? + def expectFun[A](f: A => Int) = ??? + + expectWild((i => m(i))) // manual eta expansion + expectWild(m(_)) // have to undo eta expansion with wildcard expected type + expectFun(m(_)) // have to undo eta expansion with function expected type +} diff --git a/test/files/pos/sammy_ctor_arg.scala b/test/files/pos/sammy_ctor_arg.scala new file mode 100644 index 0000000000..3c556d59f0 --- /dev/null +++ b/test/files/pos/sammy_ctor_arg.scala @@ -0,0 +1,4 @@ +trait Fun[A, B] { def apply(a: A): B } +// can't do sam expansion until the sam body def is a static method in the sam class, and not a local method in a block' +class C(f: Fun[Int, String]) +class Test extends C(s => "a")
\ No newline at end of file diff --git a/test/files/pos/sammy_exist.flags b/test/files/pos/sammy_exist.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_exist.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/sammy_implicit.scala b/test/files/pos/sammy_implicit.scala new file mode 100644 index 0000000000..ab63fc729e --- /dev/null +++ b/test/files/pos/sammy_implicit.scala @@ -0,0 +1,11 @@ +trait Fun[A, B] { def apply(a: A): B } + +abstract class SamImplicitConvert { + class Lst[T] + abstract class Str { def getBytes: Array[Int] } + def flatMap[B](f: Fun[Str, Lst[B]]): List[B] = ??? + + implicit def conv(xs: Array[Int]): Lst[Int] + + def encoded = flatMap (_.getBytes) +} diff --git a/test/files/pos/sammy_infer_argtype_subtypes.scala b/test/files/pos/sammy_infer_argtype_subtypes.scala new file mode 100644 index 0000000000..63966f879e --- /dev/null +++ b/test/files/pos/sammy_infer_argtype_subtypes.scala @@ -0,0 +1,6 @@ +trait Fun[A, B] { def apply(a: A): B } + +class SamInferResult { + def foreach[U](f: Fun[String, U]): U = ??? + def foo = foreach(println) +}
\ No newline at end of file diff --git a/test/files/pos/sammy_inferargs.scala b/test/files/pos/sammy_inferargs.scala new file mode 100644 index 0000000000..10d9b4f0dd --- /dev/null +++ b/test/files/pos/sammy_inferargs.scala @@ -0,0 +1,6 @@ +trait Proc { def apply(): Unit } +class Test { + val initCode = List[Proc]() + initCode foreach { proc => proc() } + +} diff --git a/test/files/pos/sammy_overload.flags b/test/files/pos/sammy_overload.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_overload.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/sammy_overload.scala b/test/files/pos/sammy_overload.scala index 5472248f4d..6a3c88ec55 100644 --- a/test/files/pos/sammy_overload.scala +++ b/test/files/pos/sammy_overload.scala @@ -6,4 +6,29 @@ object Test { def foo(x: String): Unit = ??? def foo(): Unit = ??? val f: Consumer[_ >: String] = foo -}
\ No newline at end of file +} + +trait A[A, B] { def apply(a: A): B } + +class ArityDisambiguate { + object O { + def m(a: A[Int, Int]) = 0 + def m(f: (Int, Int) => Int) = 1 + } + + O.m(x => x) // ok + O.m((x, y) => x) // ok +} + +class InteractionWithImplicits { + object O { + class Ev + implicit object E1 extends Ev + implicit object E2 extends Ev + def m(a: A[Int, Int])(implicit ol: E1.type) = 0 + def m(a: A[String, Int])(implicit ol: E2.type) = 1 + } + + O.m((x: Int) => 1) // ok + O.m((x: String) => 1) // ok +} diff --git a/test/files/pos/sammy_override.flags b/test/files/pos/sammy_override.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_override.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/sammy_poly.flags b/test/files/pos/sammy_poly.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_poly.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/sammy_poly.scala b/test/files/pos/sammy_poly.scala index c629be7166..ba10baea49 100644 --- a/test/files/pos/sammy_poly.scala +++ b/test/files/pos/sammy_poly.scala @@ -1,7 +1,12 @@ // test synthesizeSAMFunction where the sam type is not fully defined -class T { - trait F[T, U] { def apply(x: T): U } - // NOTE: the f(x) desugaring for now assumes the single abstract method is called 'apply' +trait F[T, R]{ def apply(x: T): R } + +class PolySammy { + (x => x + 1): F[Int, Int] + ((x: Int) => x + 1): F[Int, Int] + ((x: String) => 1): F[String, Int] + ((x: Object) => 1): F[String, Int] + def app[T, U](x: T)(f: F[T, U]): U = f(x) app(1)(x => List(x)) -}
\ No newline at end of file +} diff --git a/test/files/pos/sammy_scope.flags b/test/files/pos/sammy_scope.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_scope.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/sammy_scope.scala b/test/files/pos/sammy_scope.scala index 8f1fe7058e..9d35501a47 100644 --- a/test/files/pos/sammy_scope.scala +++ b/test/files/pos/sammy_scope.scala @@ -1,8 +1,8 @@ // test synthesizeSAMFunction: scope hygiene -abstract class SamFun[T1, R] { self => +trait SamFun[T1, R] { self => def apply(v1: T1): R // this should type check, as the apply ref is equivalent to self.apply // it shouldn't resolve to the sam's apply that's synthesized (that wouldn't type check, hence the pos test) def compose[A](g: SamFun[A, T1]): SamFun[A, R] = { x => apply(g(x)) } -}
\ No newline at end of file +} diff --git a/test/files/pos/sammy_single.flags b/test/files/pos/sammy_single.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_single.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/sammy_twice.flags b/test/files/pos/sammy_twice.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/sammy_twice.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/t4365/a_1.scala b/test/files/pos/t4365/a_1.scala index a24b57772d..e7466e0d48 100644 --- a/test/files/pos/t4365/a_1.scala +++ b/test/files/pos/t4365/a_1.scala @@ -9,7 +9,7 @@ trait SeqViewLike[+A, trait Transformed[+B] extends super[GenSeqViewLike].Transformed[B] abstract class AbstractTransformed[+B] extends Seq[B] with Transformed[B] { - def underlying: Coll = error("") + def underlying: Coll = sys.error("") } trait Reversed extends Transformed[A] with super[GenSeqViewLike].Reversed diff --git a/test/files/pos/t4365/b_1.scala b/test/files/pos/t4365/b_1.scala index e1423813f1..1158db6c32 100644 --- a/test/files/pos/t4365/b_1.scala +++ b/test/files/pos/t4365/b_1.scala @@ -10,7 +10,7 @@ self => trait Transformed[+B] { def length: Int = 0 - def apply(idx: Int): B = error("") + def apply(idx: Int): B = sys.error("") } trait Reversed extends Transformed[A] { diff --git a/test/files/pos/t8310.flags b/test/files/pos/t8310.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/pos/t8310.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/t8429.scala b/test/files/pos/t8429.scala new file mode 100644 index 0000000000..a2d32637e1 --- /dev/null +++ b/test/files/pos/t8429.scala @@ -0,0 +1,7 @@ +trait Must { def musta(str: String, i: Int): Unit } + +object Mustare { + def takesM(m: Must) = ??? + takesM{ (a, b) => println } // ok + takesM{ case (a: String, b: Int) => println("") } // should also be accepted +} diff --git a/test/files/pos/t9449.scala b/test/files/pos/t9449.scala new file mode 100644 index 0000000000..3b86dc80a0 --- /dev/null +++ b/test/files/pos/t9449.scala @@ -0,0 +1,19 @@ +trait II { + def apply(x: Int): Int +} + +object Test { + def ii(x: Int): Int = x + def test = { + val ii1: II = x => ii(x) // works + val ii2: II = ii // works (adapting `ii` to `II`) + val ii3: II = ii _ // works (failed before the fix) + // typedTyped({ii : (() => <empty>)}) + // typedEta(ii, pt = II) + // adapt(ii, pt = (? => ?)) + // instantiatedToMethodType(ii, pt = (? => ?)) + // val ii3: II = ii _ // error: + // found : Int => Int + // required: II + } +}
\ No newline at end of file diff --git a/test/files/pos/virtpatmat_exist1.scala b/test/files/pos/virtpatmat_exist1.scala index 6cad017b0b..1f24892489 100644 --- a/test/files/pos/virtpatmat_exist1.scala +++ b/test/files/pos/virtpatmat_exist1.scala @@ -1,5 +1,6 @@ import annotation.unchecked.{ uncheckedVariance=> uV } -import scala.collection.immutable.{ListMap, HashMap, ListSet, HashSet} +import scala.collection.immutable.{ListMap, ListSet} +import scala.collection.mutable.{HashMap, HashSet} object Test { class HashMapCollision1[A, +B](var hash: Int, var kvs: ListMap[A, B @uV]) extends HashMap[A, B @uV] |