Skip to content

Commit 4f4bf41

Browse files
committed
Merge remote-tracking branch 'staging/transform/constructors' into transform/constructors
Conflicts: src/dotty/tools/dotc/transform/ElimByName.scala
2 parents 8cbc5b3 + c0da421 commit 4f4bf41

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Encoding with type fields of the
2+
// variance test in pos. This time, the
3+
// test does not pass because of the encoding
4+
// This points to a difference between type members
5+
// and parameters which we should investigate further.
6+
object Test2 {
7+
8+
trait A {
9+
type X
10+
protected[this] def f(x: X): X = x
11+
}
12+
13+
trait B extends A {
14+
type X <: B
15+
def kaboom = f(new B {})
16+
}
17+
18+
// protected[this] disables variance checking
19+
// of the signature of `f`.
20+
//
21+
// C's parent list unifies A[B] with A[C]
22+
//
23+
// The protected[this] loophole is widely used
24+
// in the collections, every newBuilder method
25+
// would fail variance checking otherwise.
26+
class C extends B with A {
27+
type X <: C
28+
override protected[this] def f(c: C) = c
29+
}
30+
31+
// java.lang.ClassCastException: B$$anon$1 cannot be cast to C
32+
// at C.f(<console>:15)
33+
new C().kaboom
34+
}

tests/neg/t7093.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
object Test2 {
3+
4+
trait A {
5+
type X
6+
protected[this] def f(x: X): X = x
7+
}
8+
9+
trait B extends A {
10+
type X <: B
11+
def kaboom = f(new B {})
12+
}
13+
}

tests/pending/pos/test.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object Test {
2+
3+
object returns {
4+
5+
def foo(x: Int): Int = {
6+
return 3
7+
}
8+
}
9+
10+
}
11+
12+

tests/pos/test.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test {
2+
3+
def foo(x: Int): Int = return 3
4+
5+
}

tests/pos/trees.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Tree[T]
2+
3+
class Empty[T] extends Tree[Nothing]
4+
class Node[T](elem: T, l: Tree[T], r: Tree[T])
5+

0 commit comments

Comments
 (0)