Skip to content

Commit 77992c9

Browse files
committed
Merge remote-tracking branch 'staging/add-semantic-names' into add-semantic-names
# Conflicts: # compiler/src/dotty/tools/dotc/core/SymDenotations.scala
2 parents 1058278 + 5bada41 commit 77992c9

19 files changed

+252
-0
lines changed

tests/pending/neg/i1846.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Bug {
2+
final val x = 42
3+
val y = x
4+
x match {case y.toString => 42 case y => 42}
5+
}

tests/pending/neg/i1905.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Arr[T](val underlying: scala.Array[T]) extends AnyVal {
2+
def foo = underlying
3+
}
4+
5+
abstract class SeqMonoTransforms[+A, +Repr] {
6+
protected[this] def fromIterableWithSameElemType(): Repr
7+
def getFIWSET: Repr = fromIterableWithSameElemType
8+
}
9+
10+
class ArrOps[A](val xs: Arr[A]) extends SeqMonoTransforms[A, Arr[A]] {
11+
def fromIterableWithSameElemType(): Arr[A] = xs
12+
}
13+
14+
object Test {
15+
def main(args: Array[String]) = {
16+
val arr = new Arr(Array(1, 2, 3))
17+
val t = new ArrOps(arr)
18+
val t2 = t.getFIWSET
19+
val x = arr.foo
20+
}
21+
}

tests/pending/neg/i2104.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
case class Pair[A, B](_1: A, _2: B)
2+
3+
trait Cons[+H, +T]
4+
5+
object Cons {
6+
def apply[H, T](h: H, t: T): Cons[H, T] = ???
7+
def unapply[H, T](t: Cons[H, T]): Option[Pair[H, T]] = ???
8+
}
9+
10+
object Test {
11+
def main(args: Array[String]): Unit = {
12+
Cons(Option(1), None) match {
13+
case Cons(Some(i), None) =>
14+
i: Int // error: found: Any(i), requires: Int
15+
assert(i == 1)
16+
}
17+
}
18+
}

tests/pending/neg/match.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
object Test {
2+
3+
class Seq[T]
4+
class List[T] extends Seq[T] { def head: T = ??? }
5+
6+
val ss: Seq[Int] = ???
7+
ss match {
8+
case ss: List[int] =>
9+
val x = ss.head
10+
val y: Int = x
11+
}
12+
}
13+
object Test1 {
14+
15+
class Seq[T]
16+
class List[T] extends Seq[T] { def head: T = ??? }
17+
18+
val ss: Seq[Int] = ???
19+
ss match {
20+
case ss: List[Int] =>
21+
println(ss)
22+
}
23+
}
24+
object Test2 {
25+
26+
trait A
27+
trait B
28+
val x: A & B = ???
29+
30+
(x: A) match {
31+
case x: B =>
32+
}
33+
}

tests/pending/pos/TypeIndexing.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// works in neither scalac nor dotty, but maybe could be made to work?
2+
trait A {
3+
type T
4+
val t : T
5+
}
6+
7+
object A {
8+
def unapply(arg: A): Option[arg.T] = Some(arg.t)
9+
}
10+
11+
object Test {
12+
def use(a : A) = a match {
13+
case b @ A(t)
14+
val s: b.T = t // type mismatch.
15+
// found t.type (with underlying type <unapply-selector>.T)
16+
// required: a.T
17+
}
18+
}

tests/pending/pos/i1793.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Test {
2+
import scala.ref.WeakReference
3+
def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = {
4+
val x = wr.underlying.get
5+
if (x != null) Some(x) else None
6+
}
7+
}

tests/pending/pos/i1960.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
case class CC2[A, B](_1: A, _2: B)
2+
3+
object Test {
4+
def main(args: Array[String]): Unit = {
5+
val CC2(_, CC2(a, _)) = CC2(0, CC2(1, 2))
6+
assert(a == 1)
7+
}
8+
}

tests/pending/pos/i2032.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class foo(annotation: Any) // annotation.StaticAnnotation
2+
@foo(new AnyRef {}) trait A

tests/pending/pos/i2071.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Test {
2+
type PF[A, B] = PartialFunction[A, B]
3+
4+
val f: PF[Int, String] = {
5+
case i => "bar"
6+
}
7+
}

tests/pending/pos/i2201a.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Foo[T]
2+
3+
class Fix[F[_]](unfix: F[Fix[F]])
4+
object DocTree {
5+
type Const[T] = Foo[Int]
6+
type FixConst = Fix[Const]
7+
def docTree(s: Const[FixConst]): FixConst = new Fix(s)
8+
}

0 commit comments

Comments
 (0)