diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/i1286.scala | 16 | ||||
-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/pos/java-interop/1576/TagAnnotation.java | 3 | ||||
-rw-r--r-- | tests/pos/java-interop/1576/Test.scala | 5 | ||||
-rw-r--r-- | tests/pos/tailcall/i1614.scala | 9 | ||||
-rw-r--r-- | tests/repl/imports.check | 10 |
13 files changed, 116 insertions, 0 deletions
diff --git a/tests/neg/i1286.scala b/tests/neg/i1286.scala new file mode 100644 index 000000000..40db9ab1d --- /dev/null +++ b/tests/neg/i1286.scala @@ -0,0 +1,16 @@ +import scala.idontexist // error +import scala.io.Idontexist // error + +import scala.io +import io.Idontexist2 // error + +import scala.io.{ AnsiColor, Idontexist3 } // error + +import scala.io.{ Idontexist4 => Foo } // error +import scala.io.{ Idontexist5 => _ } // error + +import scala.language.dynamics +import scala.language.noAutoTupling +import scala.language.idontexist // error + +object Test 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/pos/java-interop/1576/TagAnnotation.java b/tests/pos/java-interop/1576/TagAnnotation.java new file mode 100644 index 000000000..3034a1a2d --- /dev/null +++ b/tests/pos/java-interop/1576/TagAnnotation.java @@ -0,0 +1,3 @@ +public @interface TagAnnotation { + public String value(); +}
\ No newline at end of file diff --git a/tests/pos/java-interop/1576/Test.scala b/tests/pos/java-interop/1576/Test.scala new file mode 100644 index 000000000..ea3d06a83 --- /dev/null +++ b/tests/pos/java-interop/1576/Test.scala @@ -0,0 +1,5 @@ +object Test { + val v: TagAnnotation = null + println(v.value) // error: value value in class TagAnnotation cannot be accessed as a + // member of TagAnnotation(Test.v) from module class Test$. +} diff --git a/tests/pos/tailcall/i1614.scala b/tests/pos/tailcall/i1614.scala new file mode 100644 index 000000000..4c10e963d --- /dev/null +++ b/tests/pos/tailcall/i1614.scala @@ -0,0 +1,9 @@ +object Foobar { + def apply(): Option[String] = { + def foobar[A](f: (String, String) => A): List[A] = List[String]() match { + case _ :: ls => foobar(f) + } + foobar((a1, a2) => (a1 + a2)).headOption + } +} + diff --git a/tests/repl/imports.check b/tests/repl/imports.check index 26b725637..b6d9ae8a7 100644 --- a/tests/repl/imports.check +++ b/tests/repl/imports.check @@ -15,4 +15,14 @@ scala> buf += xs | scala> buf ++= xs res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) +scala> import util.foo +-- Error: <console> ---------------------------------------------------------------------------------------------------- +8 |import util.foo + | ^^^ + | foo is not a member of util +scala> import util.foo.bar +-- [E008] Member Not Found Error: <console> ---------------------------------------------------------------------------- +8 |import util.foo.bar + | ^^^^^^^^ + | value `foo` is not a member of util.type - did you mean `util.Left`? scala> :quit |