diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/i1531.scala | 6 | ||||
-rw-r--r-- | tests/pos/1567/PosZInt_1.scala | 6 | ||||
-rw-r--r-- | tests/pos/1567/Test_2.scala | 3 | ||||
-rw-r--r-- | tests/pos/i1515.scala | 16 | ||||
-rw-r--r-- | tests/pos/i1540.scala | 14 | ||||
-rw-r--r-- | tests/pos/i1540b.scala | 14 | ||||
-rw-r--r-- | tests/pos/i1544.scala | 4 | ||||
-rw-r--r-- | tests/pos/i1590.scala | 10 | ||||
-rw-r--r-- | tests/run/i1543.check | 31 | ||||
-rw-r--r-- | tests/run/i1543.scala | 41 | ||||
-rw-r--r-- | tests/run/unit_erasure.scala | 16 |
11 files changed, 161 insertions, 0 deletions
diff --git a/tests/neg/i1531.scala b/tests/neg/i1531.scala new file mode 100644 index 000000000..3c05e9509 --- /dev/null +++ b/tests/neg/i1531.scala @@ -0,0 +1,6 @@ +trait T { + def f: Int +} + +class A(f: Int) extends T // error: class A needs to be abstract + diff --git a/tests/pos/1567/PosZInt_1.scala b/tests/pos/1567/PosZInt_1.scala new file mode 100644 index 000000000..60b4061e6 --- /dev/null +++ b/tests/pos/1567/PosZInt_1.scala @@ -0,0 +1,6 @@ +final class PosZInt private (val value: Int) extends AnyVal + +object PosZInt { + def from(value: Int): Option[PosZInt] = + if (value >= 0) Some(new PosZInt(value)) else None +} diff --git a/tests/pos/1567/Test_2.scala b/tests/pos/1567/Test_2.scala new file mode 100644 index 000000000..db6ca7070 --- /dev/null +++ b/tests/pos/1567/Test_2.scala @@ -0,0 +1,3 @@ +object Test { + scala.util.Try(PosZInt.from(1).get) +} diff --git a/tests/pos/i1515.scala b/tests/pos/i1515.scala new file mode 100644 index 000000000..fb3ad78ee --- /dev/null +++ b/tests/pos/i1515.scala @@ -0,0 +1,16 @@ +sealed trait Trait[T] + +final case class Case[T](e: T) extends Trait[T] + +object Demo { + def main(args: Array[String]): Unit = { + + def f[H](t: Trait[H]): Unit = + t match { + case Case(e) => println(Some(e)) + } + + f(Case(1)) + + } +} diff --git a/tests/pos/i1540.scala b/tests/pos/i1540.scala new file mode 100644 index 000000000..7aa24f459 --- /dev/null +++ b/tests/pos/i1540.scala @@ -0,0 +1,14 @@ +class Casey1(val a: Int) { + def isDefined: Boolean = true + def isDefined(x: Int): Boolean = ??? + def get: Int = a + def get(x: Int): String = ??? +} +object Casey1 { def unapply(a: Casey1) = a } + +object Test { + def main(args: Array[String]): Unit = { + val c @ Casey1(x) = new Casey1(0) + assert(x == c.get) + } +} diff --git a/tests/pos/i1540b.scala b/tests/pos/i1540b.scala new file mode 100644 index 000000000..2b4c5408e --- /dev/null +++ b/tests/pos/i1540b.scala @@ -0,0 +1,14 @@ +class Casey1[T](val a: T) { + def isDefined: Boolean = true + def isDefined(x: T): Boolean = ??? + def get: T = a + def get(x: T): String = ??? +} +object Casey1 { def unapply[T](a: Casey1[T]) = a } + +object Test { + def main(args: Array[String]): Unit = { + val c @ Casey1(x) = new Casey1(0) + assert(x == c.get) + } +} diff --git a/tests/pos/i1544.scala b/tests/pos/i1544.scala new file mode 100644 index 000000000..f98d346e8 --- /dev/null +++ b/tests/pos/i1544.scala @@ -0,0 +1,4 @@ +object Foo { + def foo(p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int, p9: Int, p10: Int, p11: Int, p12: Int, p13: Int, p14: Int, p15: Int, p16: Int, p17: Int, p18: Int, p19: Int, p20: Int, p21: Int, p22: Int, p23: Int, p24: Int, p25: Int, p26: Int, p27: Int, p28: Int, p29: Int, p30: Int, p31: Int, p32: Int, p33: Int, p34: Int, p35: Int, p36: Int, p37: Int, p38: Int, p39: Int, p40: Int, p41: Int, p42: Int, p43: Int, p44: Int, p45: Int, p46: Int, p47: Int, p48: Int, p49: Int, p50: Int, p51: Int, p52: Int, p53: Int, p54: Int, p55: Int, p56: Int, p57: Int, p58: Int, p59: Int, p60: Int, p61: Int, p62: Int, p63: Int, p64: Int, p65: Int, p66: Int, p67: Int, p68: Int, p69: Int, p70: Int, p71: Int, p72: Int, p73: Int, p74: Int, p75: Int, p76: Int, p77: Int, p78: Int, p79: Int, p80: Int, p81: Int, p82: Int, p83: Int, p84: Int, p85: Int, p86: Int, p87: Int, p88: Int, p89: Int, p90: Int, p91: Int, p92: Int, p93: Int, p94: Int, p95: Int, p96: Int, p97: Int, p98: Int, p99: Int, p100: Int, p101: Int, p102: Int, p103: Int, p104: Int, p105: Int, p106: Int, p107: Int, p108: Int, p109: Int): Int = 42 + foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109) +} diff --git a/tests/pos/i1590.scala b/tests/pos/i1590.scala new file mode 100644 index 000000000..ab922c218 --- /dev/null +++ b/tests/pos/i1590.scala @@ -0,0 +1,10 @@ +case class W[T](seq: Option[Option[T]] = Option.empty) +object W { + def apply[T] = new W[T]() +} + +case class V[T](vv: W[W[T]] = W.apply) +object Test { + W[Int]() + // V[Int]() fails in scalac and dotty: both instantiate the vv-default to W[Nothing] +} diff --git a/tests/run/i1543.check b/tests/run/i1543.check new file mode 100644 index 000000000..10adcaf83 --- /dev/null +++ b/tests/run/i1543.check @@ -0,0 +1,31 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 diff --git a/tests/run/i1543.scala b/tests/run/i1543.scala new file mode 100644 index 000000000..268bc717b --- /dev/null +++ b/tests/run/i1543.scala @@ -0,0 +1,41 @@ + +object Test extends dotty.runtime.LegacyApp { + new Bar().foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31) +} + + +class Bar { + def foo(p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int, p9: Int, p10: Int, p11: Int, p12: Int, p13: Int, p14: Int, p15: Int, p16: Int, p17: Int, p18: Int, p19: Int, p20: Int, p21: Int, p22: Int, p23: Int, p24: Int, p25: Int, p26: Int, p27: Int, p28: Int, p29: Int, p30: Int, p31: Int): Unit = { + println(p1) + println(p2) + println(p3) + println(p4) + println(p5) + println(p6) + println(p7) + println(p8) + println(p9) + println(p10) + println(p11) + println(p12) + println(p13) + println(p14) + println(p15) + println(p16) + println(p17) + println(p18) + println(p19) + println(p20) + println(p21) + println(p22) + println(p23) + println(p24) + println(p25) + println(p26) + println(p27) + println(p28) + println(p29) + println(p30) + println(p31) + } +} diff --git a/tests/run/unit_erasure.scala b/tests/run/unit_erasure.scala new file mode 100644 index 000000000..51ccf0a16 --- /dev/null +++ b/tests/run/unit_erasure.scala @@ -0,0 +1,16 @@ +class A { + def foo1[T]: Unit = {} + def foo2[T](): Unit = {} + def foo3[T]()(): Unit = {} + def foo4: Unit = {} + def foo5(): Unit = {} + def foo6()(): Unit = {} +} + +object Test { + def main(args: Array[String]): Unit = { + classOf[A].getMethods.toList.filter(_.getName.startsWith("foo")).foreach { m => + assert(m.getGenericReturnType == Void.TYPE, s"Method does not return void: `${m}`") + } + } +}
\ No newline at end of file |