diff options
author | Martijn Hoekstra <Martijn Hoekstra> | 2016-09-03 12:10:53 +0200 |
---|---|---|
committer | Martijn Hoekstra <Martijn Hoekstra> | 2016-09-07 22:32:51 +0200 |
commit | 32819e2edc88dd06095704c04ed9c2dd0603386f (patch) | |
tree | 5ac33b7a4fc11fe5b13aeae26e963e5553e97fad /tests/pos/valueclasses | |
parent | 6bce106fea7ce10eefc864a6e7c1351675065880 (diff) | |
download | dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.tar.gz dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.tar.bz2 dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.zip |
honor -encoding compiler flag and defaults
rename test/pos/valueclasses to pos_valueclasses
tests/pos/valueclasses generates a valueclasses.flags
file in /tests/partest-generated/pos that conflicts
with the valueClasses.flags file that
tests/neg/valueClasses.scala tries to create
Diffstat (limited to 'tests/pos/valueclasses')
28 files changed, 0 insertions, 398 deletions
diff --git a/tests/pos/valueclasses/nullAsInstanceOfVC.scala b/tests/pos/valueclasses/nullAsInstanceOfVC.scala deleted file mode 100644 index 43af839ec..000000000 --- a/tests/pos/valueclasses/nullAsInstanceOfVC.scala +++ /dev/null @@ -1,29 +0,0 @@ -package nullAsInstanceOfVC - -// These issues were originally reported in SI-5866 and SI-8097 -// FIXME: Make this a run test once we have run tests. - -object VCNull { - case class Foo(d: Double) extends AnyVal { - override def toString = s"Foo($d)" - } - case class Bar(s: String) extends AnyVal { - override def toString = s"Bar($s)" - } - - def testDirect(): Unit = { - val fooDirect: Foo = null.asInstanceOf[Foo] - val barDirect: Bar = null.asInstanceOf[Bar] - } - - def testIndirect(): Unit = { - val fooIndirect: Foo = { val n: Any = null; n.asInstanceOf[Foo] } - val barIndirect: Bar = { val n: Any = null; n.asInstanceOf[Bar] } - } - - def nullOf[T]: T = null.asInstanceOf[T] - def testGeneric(): Unit = { - val fooGeneric: Foo = nullOf[Foo] - val barGeneric: Bar = nullOf[Bar] - } -} diff --git a/tests/pos/valueclasses/optmatch.scala b/tests/pos/valueclasses/optmatch.scala deleted file mode 100644 index a7995a455..000000000 --- a/tests/pos/valueclasses/optmatch.scala +++ /dev/null @@ -1,35 +0,0 @@ -package optmatch - -// final case class NonZeroLong(value: Long) extends AnyVal { -// def get: Long = value -// def isEmpty: Boolean = get == 0l -// } - -class NonZeroLong(val value: Long) extends AnyVal { - def get: Long = value - def isDefined: Boolean = get != 0l -} -object NonZeroLong { - def unapply(value: Long): NonZeroLong = new NonZeroLong(value) -} - - -object Foo { - def unapply(x: Int): NonZeroLong = new NonZeroLong(1L << x) - // public long unapply(int); - // 0: lconst_1 - // 1: iload_1 - // 2: lshl - // 3: lreturn -} - -object Test { - def f(x: Int): Int = x match { - case Foo(1024l) => 1 - case _ => 2 - } - def main(args: Array[String]): Unit = { - println(f(10)) - println(f(11)) - } -} diff --git a/tests/pos/valueclasses/paramlists.scala b/tests/pos/valueclasses/paramlists.scala deleted file mode 100644 index f390a44e0..000000000 --- a/tests/pos/valueclasses/paramlists.scala +++ /dev/null @@ -1,37 +0,0 @@ -package paramlists - -class Meter[T](val x: T) extends AnyVal { - def zero: T = x - def zero2[M >: T]: M = x - def one(): T = x - def one2[M >: T](): M = x - def one3(x: T): T = x - def one4[M >: T](x: M): M = x - def two(x: T)(y: T): T = y - def two2[M >: T](x: T)(y: M): M = y -} - -object Test { - def test: Unit = { - val m1 = new Meter(1) - m1.zero - m1.zero2 - m1.one - m1.one2 - m1.one3(10) - m1.two(11)(12) - m1.two2(11)(12) - - { - import m1._ - - zero - zero2 - one - one2 - one3(10) - two(11)(12) - two2(11)(12) - } - } -} diff --git a/tests/pos/valueclasses/privatethisparam.scala b/tests/pos/valueclasses/privatethisparam.scala deleted file mode 100644 index 77ca9851c..000000000 --- a/tests/pos/valueclasses/privatethisparam.scala +++ /dev/null @@ -1,18 +0,0 @@ -package privatethisparam - -class Meter[T](x: T) extends AnyVal { - def zero: T = x -} - -class Meter2(private[this] val x: Int) extends AnyVal { - def foo = x -} - -object Test { - def bar = new Meter2(42) - def useZero = new Meter(5).zero - def test: Unit = { - val m1 = new Meter(1) - m1.zero - } -}
\ No newline at end of file diff --git a/tests/pos/valueclasses/t5667.scala b/tests/pos/valueclasses/t5667.scala deleted file mode 100644 index 80efb181b..000000000 --- a/tests/pos/valueclasses/t5667.scala +++ /dev/null @@ -1,6 +0,0 @@ -package t5667 - -object Main { - implicit class C(val s: String) extends AnyVal - implicit class C2(val s: String) extends AnyRef -} diff --git a/tests/pos/valueclasses/t5853.scala b/tests/pos/valueclasses/t5853.scala deleted file mode 100644 index 82ac9dd1d..000000000 --- a/tests/pos/valueclasses/t5853.scala +++ /dev/null @@ -1,57 +0,0 @@ -package t5853 - - - - - - - - -final class C(val x: Int) extends AnyVal { - def ppp[@specialized(Int) T](y: T) = () -} - - -class Foo { - def f = new C(1) ppp 2 -} - - -/* Original SI-5853 test-case. */ - -object Bippy { - implicit final class C(val x: Int) extends AnyVal { - def +++[@specialized T](y: T) = () - } - def f = 1 +++ 2 -} - - -/* Few more examples. */ - -final class C2(val x: Int) extends AnyVal { - def +++[@specialized(Int) T](y: T) = () -} - - -class Foo2 { - def f = new C2(1) +++ 2 -} - - -object Arrow { - implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { - @inline def ->>[B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) - } - - def foo = 1 ->> 2 -} - - -object SpecArrow { - implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { - @inline def ->> [@specialized(Int) B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) - } - - def foo = 1 ->> 2 -} diff --git a/tests/pos/valueclasses/t5953.scala b/tests/pos/valueclasses/t5953.scala deleted file mode 100644 index 669fac7df..000000000 --- a/tests/pos/valueclasses/t5953.scala +++ /dev/null @@ -1,18 +0,0 @@ -package t5953 - -import scala.collection.{ mutable, immutable, generic, GenTraversableOnce } - -package object foo { - @inline implicit class TravOps[A, CC[A] <: GenTraversableOnce[A]](val coll: CC[A]) extends AnyVal { - def build[CC2[X]](implicit cbf: generic.CanBuildFrom[Nothing, A, CC2[A]]): CC2[A] = { - cbf() ++= coll.toIterator result - } - } -} - -package foo { - object Test { - def f1[T](xs: Traversable[T]) = xs.to[immutable.Vector] - def f2[T](xs: Traversable[T]) = xs.build[immutable.Vector] - } -} diff --git a/tests/pos/valueclasses/t6029.scala b/tests/pos/valueclasses/t6029.scala deleted file mode 100644 index 13f8f8830..000000000 --- a/tests/pos/valueclasses/t6029.scala +++ /dev/null @@ -1,5 +0,0 @@ -package t6029 - -final case class V[A](x: A) extends AnyVal { - def flatMap[B](f: A => V[B]) = if (true) this else f(x) -} diff --git a/tests/pos/valueclasses/t6034.scala b/tests/pos/valueclasses/t6034.scala deleted file mode 100644 index 8e2fb625c..000000000 --- a/tests/pos/valueclasses/t6034.scala +++ /dev/null @@ -1,3 +0,0 @@ -package t6034 - -final class OptPlus[+A](val x: A) extends AnyVal { } diff --git a/tests/pos/valueclasses/t6215.scala b/tests/pos/valueclasses/t6215.scala deleted file mode 100644 index 579503e6c..000000000 --- a/tests/pos/valueclasses/t6215.scala +++ /dev/null @@ -1,3 +0,0 @@ -package t6215 - -class Foo(val v: String) extends AnyVal { private def len = v.length ; def f = len } diff --git a/tests/pos/valueclasses/t6260.scala b/tests/pos/valueclasses/t6260.scala deleted file mode 100644 index 675c3c16a..000000000 --- a/tests/pos/valueclasses/t6260.scala +++ /dev/null @@ -1,19 +0,0 @@ -package t6260 - -class Box[X](val x: X) extends AnyVal { - def map[Y](f: X => Y): Box[Y] = - ((bx: Box[X]) => new Box(f(bx.x)))(this) -} - -object Test { - def map2[X, Y](self: Box[X], f: X => Y): Box[Y] = - ((bx: Box[X]) => new Box(f(bx.x)))(self) - - def main(args: Array[String]): Unit = { - val f = (x: Int) => x + 1 - val g = (x: String) => x + x - - map2(new Box(42), f) - new Box("abc") map g - } -} diff --git a/tests/pos/valueclasses/t6260a.scala b/tests/pos/valueclasses/t6260a.scala deleted file mode 100644 index e29f10452..000000000 --- a/tests/pos/valueclasses/t6260a.scala +++ /dev/null @@ -1,17 +0,0 @@ -package t6260a - -final class Option[+A](val value: A) extends AnyVal - -// Was: sandbox/test.scala:21: error: bridge generated for member method f: ()Option[A] in class Bar -// which overrides method f: ()Option[A] in class Foo" -abstract class Foo[A] { def f(): Option[A] } - class Bar[A] extends Foo[A] { def f(): Option[A] = ??? } - -// User reported this as erroneous but I couldn't reproduce with 2.10.{0,1,2,3} -// https://issues.scala-lang.org/browse/SI-6260?focusedCommentId=64764&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-64764 -// I suspect he whittled down the example too far. -class Wrapper(val value: Int) extends AnyVal -abstract class Test { def check(the: Wrapper): Boolean } -object T { - new Test { def check(the: Wrapper) = true } -} diff --git a/tests/pos/valueclasses/t6260b.scala b/tests/pos/valueclasses/t6260b.scala deleted file mode 100644 index fb9a2961b..000000000 --- a/tests/pos/valueclasses/t6260b.scala +++ /dev/null @@ -1,5 +0,0 @@ -package t6260b - - -class X(val value: Object) extends AnyVal { def or(alt: => X): X = this } -class Y { def f = new X("") or new X("") } diff --git a/tests/pos/valueclasses/t6358.scala b/tests/pos/valueclasses/t6358.scala deleted file mode 100644 index 291ae2e9e..000000000 --- a/tests/pos/valueclasses/t6358.scala +++ /dev/null @@ -1,8 +0,0 @@ -package t6358 - -class L(val t: Int) extends AnyVal { - def lazyString = { - lazy val x = t.toString - () => x - } -} diff --git a/tests/pos/valueclasses/t6358_2.scala b/tests/pos/valueclasses/t6358_2.scala deleted file mode 100644 index effac505a..000000000 --- a/tests/pos/valueclasses/t6358_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -package t6358_2 - -class Y[T](val i: Option[T]) extends AnyVal { - def q: List[T] = { - lazy val e: List[T] = i.toList - e - } -} diff --git a/tests/pos/valueclasses/t6601/PrivateValueClass_1.scala b/tests/pos/valueclasses/t6601/PrivateValueClass_1.scala deleted file mode 100644 index fc6f3e422..000000000 --- a/tests/pos/valueclasses/t6601/PrivateValueClass_1.scala +++ /dev/null @@ -1,3 +0,0 @@ -package t6601 - -class V private (val a: Any) extends AnyVal diff --git a/tests/pos/valueclasses/t6601/UsePrivateValueClass_2.scala b/tests/pos/valueclasses/t6601/UsePrivateValueClass_2.scala deleted file mode 100644 index acd0dbef9..000000000 --- a/tests/pos/valueclasses/t6601/UsePrivateValueClass_2.scala +++ /dev/null @@ -1,12 +0,0 @@ -package t6601 - -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/tests/pos/valueclasses/t6651.scala b/tests/pos/valueclasses/t6651.scala deleted file mode 100644 index 6201b6de3..000000000 --- a/tests/pos/valueclasses/t6651.scala +++ /dev/null @@ -1,35 +0,0 @@ -package t6651 - -class YouAreYourself[A <: AnyRef](val you: A) extends AnyVal { - def yourself: you.type = you -} - -object Test { - val s = "" - val s1: s.type = new YouAreYourself[s.type](s).yourself -} - -trait Path { - type Dep <: AnyRef -} - -final class ValueClass[P <: Path](val path: P) extends AnyVal { - import path.Dep - - def apply(dep: Dep)(d2: dep.type, foo: Int): (Dep, d2.type) = (d2, d2) - - // This generates dodgy code; note `ValueClass.this`: - // - // final def bounds$extension[D >: Nothing <: ValueClass.this.path.Dep, - // P >: Nothing <: Path] - // ($this: ValueClass[P]) - // (dep: D) - // (d2: dep.type, foo: Int): (D, d2.type) = scala.Tuple2.apply[D, d2.type](d2, d2); - // - // Nothing crashes down the line, but it certainly doesn't conform to best-practices. - // - // An better alternative would be to add a type parameter for the (singleton) type of - // the wrapped value. - def bounds[D <: Dep](dep: D)(d2: dep.type, foo: Int): (D, d2.type) = (d2, d2) -} - diff --git a/tests/pos/valueclasses/t7818.scala b/tests/pos/valueclasses/t7818.scala deleted file mode 100644 index 31f542366..000000000 --- a/tests/pos/valueclasses/t7818.scala +++ /dev/null @@ -1,12 +0,0 @@ -package t7818 - -class Observable1[+T](val asJava: JObservable[_ <: T]) extends AnyVal { - private def foo[X](a: JObservable[X]): JObservable[X] = ??? - // was generating a type error as the type of the RHS included an existential - // skolem based on the class type parameter `T`, which did not conform - // to the typer parameter of the extension method into which the RHS is - // transplanted. - def synchronize: Observable1[T] = new Observable1(foo(asJava)) -} - -class JObservable[T] diff --git a/tests/pos/valueclasses/t8011.scala b/tests/pos/valueclasses/t8011.scala deleted file mode 100644 index 88b4b53aa..000000000 --- a/tests/pos/valueclasses/t8011.scala +++ /dev/null @@ -1,10 +0,0 @@ -package t8011 - -class ThingOps1(val x: String) extends AnyVal { - def fn[A]: Any = { - new X[A] { def foo(a: A) = a } - 0 - } -} - -trait X[B] { def foo(a: B): Any } diff --git a/tests/pos/valueclasses/t9298/JUse.java b/tests/pos/valueclasses/t9298/JUse.java deleted file mode 100644 index a872c895a..000000000 --- a/tests/pos/valueclasses/t9298/JUse.java +++ /dev/null @@ -1,7 +0,0 @@ -package t9298; - -class JUse { - public static Meter jm() { - return new Meter(2); - } -} diff --git a/tests/pos/valueclasses/t9298/Meter.scala b/tests/pos/valueclasses/t9298/Meter.scala deleted file mode 100644 index 290b28509..000000000 --- a/tests/pos/valueclasses/t9298/Meter.scala +++ /dev/null @@ -1,3 +0,0 @@ -package t9298 - -class Meter(val x: Int) extends AnyVal diff --git a/tests/pos/valueclasses/t9298/Use.scala b/tests/pos/valueclasses/t9298/Use.scala deleted file mode 100644 index 41f1fb035..000000000 --- a/tests/pos/valueclasses/t9298/Use.scala +++ /dev/null @@ -1,9 +0,0 @@ -// TODO: this should be a run test once we have run tests - -package t9298 - -object Use { - def main(args: Array[String]): Unit = { - val x: Meter = JUse.jm - } -} diff --git a/tests/pos/valueclasses/value-class-override-no-spec.flags b/tests/pos/valueclasses/value-class-override-no-spec.flags deleted file mode 100644 index a7e64e4f0..000000000 --- a/tests/pos/valueclasses/value-class-override-no-spec.flags +++ /dev/null @@ -1 +0,0 @@ --no-specialization
\ No newline at end of file diff --git a/tests/pos/valueclasses/value-class-override-no-spec.scala b/tests/pos/valueclasses/value-class-override-no-spec.scala deleted file mode 100644 index 058e3e911..000000000 --- a/tests/pos/valueclasses/value-class-override-no-spec.scala +++ /dev/null @@ -1,11 +0,0 @@ -package value_class_override_no_spec - -// There are two versions of this tests: one with and one without specialization. -// The bug was only exposed *without* specialization. -trait T extends Any { - def x: Any -} - -final class StringOps(val repr0: String) extends AnyVal with T { - def x = () -} diff --git a/tests/pos/valueclasses/value-class-override-spec.scala b/tests/pos/valueclasses/value-class-override-spec.scala deleted file mode 100644 index c315be8d0..000000000 --- a/tests/pos/valueclasses/value-class-override-spec.scala +++ /dev/null @@ -1,11 +0,0 @@ -package value_class_override_spec - -// There are two versions of this tests: one with and one without specialization. -// The bug was only exposed *without* specialization. -trait T extends Any { - def x: Any -} - -final class StringOps(val repr0: String) extends AnyVal with T { - def x = () -} diff --git a/tests/pos/valueclasses/xlint1.flags b/tests/pos/valueclasses/xlint1.flags deleted file mode 100644 index 7949c2afa..000000000 --- a/tests/pos/valueclasses/xlint1.flags +++ /dev/null @@ -1 +0,0 @@ --Xlint -Xfatal-warnings diff --git a/tests/pos/valueclasses/xlint1.scala b/tests/pos/valueclasses/xlint1.scala deleted file mode 100644 index c2f39f9b3..000000000 --- a/tests/pos/valueclasses/xlint1.scala +++ /dev/null @@ -1,15 +0,0 @@ -package xlint1 - -package object foo { - implicit class Bar[T](val x: T) extends AnyVal { - def bippy = 1 - } -} - -package foo { - object Baz { - def main(args: Array[String]): Unit = { - "abc".bippy - } - } -} |