diff options
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/lubs.scala | 3 | ||||
-rw-r--r-- | test/files/pos/presuperContext.scala | 13 | ||||
-rw-r--r-- | test/files/pos/t1014.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t1803.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t1803.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t6482.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t6601/PrivateValueClass_1.scala | 1 | ||||
-rw-r--r-- | test/files/pos/t6601/UsePrivateValueClass_2.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t7022.scala | 9 | ||||
-rw-r--r-- | test/files/pos/t7033.scala | 15 |
10 files changed, 68 insertions, 1 deletions
diff --git a/test/files/pos/lubs.scala b/test/files/pos/lubs.scala new file mode 100644 index 0000000000..d7651f86b0 --- /dev/null +++ b/test/files/pos/lubs.scala @@ -0,0 +1,3 @@ +object Test { + List(new { def f = 1; def g = 1}, new { def f = 2}).map(_.f) +} diff --git a/test/files/pos/presuperContext.scala b/test/files/pos/presuperContext.scala new file mode 100644 index 0000000000..cc34263073 --- /dev/null +++ b/test/files/pos/presuperContext.scala @@ -0,0 +1,13 @@ +class A { + class C extends { val x: A = this } with AnyRef +} + +class B(x: Int) + +class D { + class C(x: Int) extends B({val test: D = this; x}) { + def this() { + this({val test: D = this; 1}) + } + } +} diff --git a/test/files/pos/t1014.scala b/test/files/pos/t1014.scala index 1ac87b225b..3fc10d10dc 100644 --- a/test/files/pos/t1014.scala +++ b/test/files/pos/t1014.scala @@ -1,6 +1,8 @@ import scala.xml.{NodeSeq, Elem} -class EO extends App with Moo{ +class EO extends App with Moo { + // return type is Flog, inherited from overridden method. + // implicit conversions are applied because expected type `pt` is `Flog` when `computeType(rhs, pt)`. def cat = <cat>dog</cat> implicit def nodeSeqToFlog(in: Elem): Flog = new Flog(in) diff --git a/test/files/pos/t1803.flags b/test/files/pos/t1803.flags new file mode 100644 index 0000000000..d1a8244169 --- /dev/null +++ b/test/files/pos/t1803.flags @@ -0,0 +1 @@ +-Yinfer-argument-types
\ No newline at end of file diff --git a/test/files/pos/t1803.scala b/test/files/pos/t1803.scala new file mode 100644 index 0000000000..42f4e784a3 --- /dev/null +++ b/test/files/pos/t1803.scala @@ -0,0 +1,2 @@ +class A { def foo[A](a: A) = a } +class B extends A { override def foo[A](b) = b } diff --git a/test/files/pos/t6482.scala b/test/files/pos/t6482.scala new file mode 100644 index 0000000000..24ea38e519 --- /dev/null +++ b/test/files/pos/t6482.scala @@ -0,0 +1,11 @@ +final class TraversableOnceOps[+A](val collection: TraversableOnce[A]) extends AnyVal { + def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] = + if (collection.isEmpty) None else Some(collection.reduceLeft[B](op)) +} +// error: type arguments [B] do not conform to method reduceLeft's type parameter bounds [B >: A] +// if (collection.isEmpty) None else Some(collection.reduceLeft[B](op)) +// ^ + +class Foo[+A <: AnyRef](val xs: List[A]) extends AnyVal { + def baz[B >: A](x: B): List[B] = x :: xs +} diff --git a/test/files/pos/t6601/PrivateValueClass_1.scala b/test/files/pos/t6601/PrivateValueClass_1.scala new file mode 100644 index 0000000000..85c3687137 --- /dev/null +++ b/test/files/pos/t6601/PrivateValueClass_1.scala @@ -0,0 +1 @@ +class V private (val a: Any) extends AnyVal
\ No newline at end of file diff --git a/test/files/pos/t6601/UsePrivateValueClass_2.scala b/test/files/pos/t6601/UsePrivateValueClass_2.scala new file mode 100644 index 0000000000..461b8397b2 --- /dev/null +++ b/test/files/pos/t6601/UsePrivateValueClass_2.scala @@ -0,0 +1,10 @@ +object Test { + // After the first attempt to make seprately compiled value + // classes respect the privacy of constructors, we got: + // + // exception when typing v.a().==(v.a())/class scala.reflect.internal.Trees$Apply + // constructor V in class V cannot be accessed in object Test in file test/files/pos/t6601/UsePrivateValueClass_2.scala + // scala.reflect.internal.Types$TypeError: constructor V in class V cannot be accessed in object Test + def foo(v: V) = v.a == v.a + def bar(v: V) = v == v +} diff --git a/test/files/pos/t7022.scala b/test/files/pos/t7022.scala new file mode 100644 index 0000000000..0609e2d250 --- /dev/null +++ b/test/files/pos/t7022.scala @@ -0,0 +1,9 @@ +class Catch[+T] { + def either[U >: T](body: => U): Either[Throwable, U] = ??? +} + +object Test { + implicit class RichCatch[T](val c: Catch[T]) extends AnyVal { + def validation[U >: T](u: => U): Either[Throwable, U] = c.either(u) + } +} diff --git a/test/files/pos/t7033.scala b/test/files/pos/t7033.scala new file mode 100644 index 0000000000..a4d256673b --- /dev/null +++ b/test/files/pos/t7033.scala @@ -0,0 +1,15 @@ +import language.higherKinds +object Wrap { + implicit class X[X](val a: X) + + X[Int](0) +} + +class Wrap { + implicit class Y[Y](val a: Y) + Y[Int](0) + implicit class Z[Z[_]](val a: Z[Wrap.this.Z[Z]]) + Z[List](List(new Z[List](null))) +} + +case class X[X](val a: X) |