Skip to content

Commit 402b5e4

Browse files
committed
Pending and passing tests.
Move now-passing SI-963 test into neg. Test for partial specialization. Pending test for SI-5008. Pending test for SI-4649. Abstract array type test.
1 parent 0d7952f commit 402b5e4

File tree

8 files changed

+236
-3
lines changed

8 files changed

+236
-3
lines changed

test/files/neg/t963b.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
t963b.scala:25: error: type mismatch;
2+
found : B.type
3+
required: AnyRef{val y: A}
4+
B.f(B)
5+
^
6+
one error found

test/pending/neg/t963.scala renamed to test/files/neg/t963b.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ trait A {
55
}
66

77
object B {
8-
def f(x : { val y : A }) { x.y.v = x.y.v }
9-
8+
def f(x : { val y : A }) { x.y.v = x.y.v }
9+
1010
var a : A = _
1111
var b : Boolean = false
1212
def y : A = {
@@ -21,6 +21,6 @@ object B {
2121
}
2222
}
2323

24-
object Test extends Application {
24+
object Test extends App {
2525
B.f(B)
2626
}

test/files/pos/arrays3.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trait Foo {
2+
type Repr <: String
3+
def f2(x: Repr) = x.length
4+
}
5+
trait Fooz[Repr <: Array[_]] {
6+
def f0(x: Repr) = x.length
7+
}
8+
9+
trait Bar[Repr <: List[_]] extends Foo with Fooz[Array[Int]] {
10+
def f1(x: Repr) = x.length
11+
}

test/pending/neg/t5008.scala

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// These are members of class bar.C, completely unrelated to class foo.A.
2+
// The types shown below include types defined within foo.A which are:
3+
//
4+
// - qualified private
5+
// - qualified protected
6+
// - object protected
7+
//
8+
// val a : foo.A = { /* compiled code */ }
9+
// val xprot1 : java.lang.Object with foo.A.FooProt1 = { /* compiled code */ }
10+
// val xprot2 : java.lang.Object with foo.A.FooProt2 = { /* compiled code */ }
11+
// val xprot3 : java.lang.Object with foo.A.FooProt3 = { /* compiled code */ }
12+
// val xprot4 : java.lang.Object with foo.A.FooProt4 = { /* compiled code */ }
13+
// val xpriv3 : java.lang.Object with foo.A.FooPriv3 = { /* compiled code */ }
14+
// val xpriv4 : java.lang.Object with foo.A.FooPriv4 = { /* compiled code */ }
15+
//
16+
// Indeed it will tell me a type which I cannot access:
17+
//
18+
// scala> new bar.C
19+
// res0: bar.C = bar.C@1339a0dc
20+
//
21+
// scala> res0.xpriv3
22+
// res1: java.lang.Object with res0.a.FooPriv3 = bar.C$$anon$29@39556aec
23+
//
24+
// scala> new res0.a.FooPriv3
25+
// <console>:9: error: trait FooPriv3 in class A cannot be accessed in foo.A
26+
// new res0.a.FooPriv3
27+
// ^
28+
// Looking at how the compiler prints the types of those vals, one
29+
// develops a suspicion how some of it is being allowed:
30+
//
31+
// val xpriv4: C.this.a.FooPriv4
32+
// val xpriv3: C.this.a.FooPriv3
33+
// val xprot4: C.this.a.FooProt4
34+
// val xprot3: C.this.a.FooProt3
35+
// val xprot2: C.this.a.FooProt2
36+
// val xprot1: C.this.a.FooProt1
37+
//
38+
// That is, "this" is in the prefix somewhere, it's just not a "this"
39+
// which has any bearing.
40+
41+
package foo {
42+
class A {
43+
trait Foo
44+
45+
protected trait FooProt1
46+
protected[this] trait FooProt2
47+
protected[foo] trait FooProt3
48+
protected[A] trait FooProt4
49+
50+
private trait FooPriv1
51+
private[this] trait FooPriv2
52+
private[foo] trait FooPriv3
53+
private[A] trait FooPriv4
54+
55+
type BarProt1 = FooProt1
56+
type BarProt2 = FooProt2
57+
type BarProt3 = FooProt3
58+
type BarProt4 = FooProt4
59+
60+
// type BarPriv1 = FooPriv1
61+
// type BarPriv2 = FooPriv2
62+
type BarPriv3 = FooPriv3
63+
type BarPriv4 = FooPriv4
64+
65+
def fprot1(x: FooProt1) = x
66+
def fprot2(x: FooProt2) = x
67+
def fprot3(x: FooProt3) = x
68+
def fprot4(x: FooProt4) = x
69+
70+
// def fpriv1(x: FooPriv1) = x
71+
// def fpriv2(x: FooPriv2) = x
72+
def fpriv3(x: FooPriv3) = x
73+
def fpriv4(x: FooPriv4) = x
74+
75+
val yprot1 = new FooProt1 { }
76+
val yprot2 = new FooProt2 { }
77+
val yprot3 = new FooProt3 { }
78+
val yprot4 = new FooProt4 { }
79+
80+
// val ypriv1 = new FooPriv1 { }
81+
// val ypriv2 = new FooPriv2 { }
82+
val ypriv3 = new FooPriv3 { }
83+
val ypriv4 = new FooPriv4 { }
84+
85+
def fpriv_alt1(x: FooPriv1) = 0 // !!! isn't the private type now in the signature of the (public) method?
86+
def fpriv_alt2(x: FooPriv2) = 0 // !!! isn't the private[this] type now in the signature of the (public) method?
87+
}
88+
// Same package, subclass
89+
class B extends A {
90+
val xprot1 = new BarProt1 { }
91+
val xprot2 = new BarProt2 { }
92+
val xprot3 = new BarProt3 { }
93+
val xprot4 = new BarProt4 { }
94+
95+
// val xpriv1 = new BarPriv1 { }
96+
// val xpriv2 = new BarPriv2 { }
97+
val xpriv3 = new BarPriv3 { }
98+
val xpriv4 = new BarPriv4 { }
99+
100+
override def fprot1(x: BarProt1) = x
101+
override def fprot2(x: BarProt2) = x
102+
override def fprot3(x: BarProt3) = x
103+
override def fprot4(x: BarProt4) = x
104+
105+
// override def fpriv1(x: BarPriv1) = x
106+
// override def fpriv2(x: BarPriv2) = x
107+
override def fpriv3(x: BarPriv3) = x
108+
override def fpriv4(x: BarPriv4) = x
109+
}
110+
// Same package, unrelated class
111+
class C {
112+
val a = new A
113+
import a._
114+
115+
val xprot1 = new BarProt1 { }
116+
val xprot2 = new BarProt2 { }
117+
val xprot3 = new BarProt3 { }
118+
val xprot4 = new BarProt4 { }
119+
120+
// val xpriv1 = new BarPriv1 { }
121+
// val xpriv2 = new BarPriv2 { }
122+
val xpriv3 = new BarPriv3 { }
123+
val xpriv4 = new BarPriv4 { }
124+
}
125+
}
126+
127+
package bar {
128+
// Different package, subclass
129+
class B extends foo.A {
130+
val xprot1 = new BarProt1 { }
131+
val xprot2 = new BarProt2 { }
132+
val xprot3 = new BarProt3 { }
133+
val xprot4 = new BarProt4 { }
134+
135+
// val xpriv1 = new BarPriv1 { }
136+
// val xpriv2 = new BarPriv2 { }
137+
val xpriv3 = new BarPriv3 { }
138+
val xpriv4 = new BarPriv4 { }
139+
140+
override def fprot1(x: BarProt1) = x
141+
override def fprot2(x: BarProt2) = x
142+
override def fprot3(x: BarProt3) = x
143+
override def fprot4(x: BarProt4) = x
144+
145+
// override def fpriv1(x: BarPriv1) = x
146+
// override def fpriv2(x: BarPriv2) = x
147+
override def fpriv3(x: BarPriv3) = x
148+
override def fpriv4(x: BarPriv4) = x
149+
}
150+
// Different package, unrelated class
151+
class C {
152+
val a = new foo.A
153+
import a._
154+
155+
val xprot1 = new BarProt1 { }
156+
val xprot2 = new BarProt2 { }
157+
val xprot3 = new BarProt3 { }
158+
val xprot4 = new BarProt4 { }
159+
160+
// val xpriv1 = new BarPriv1 { }
161+
// val xpriv2 = new BarPriv2 { }
162+
val xpriv3 = new BarPriv3 { }
163+
val xpriv4 = new BarPriv4 { }
164+
}
165+
}

test/pending/pos/t4649.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xfatal-warnings

test/pending/pos/t4649.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
// @annotation.tailrec
3+
def lazyFilter[E](s: Stream[E], p: E => Boolean): Stream[E] = s match {
4+
case h #:: t => if (p(h)) h #:: lazyFilter(t, p) else lazyFilter(t, p)
5+
}
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Fn$mcII$sp
2+
Fn$mcLI$sp
3+
Fn$mcLI$sp
4+
Fn$mcIL$sp
5+
Fn
6+
Fn
7+
Fn$mcIL$sp
8+
Fn
9+
Fn
10+
Fn3
11+
Fn3$mcLIDF$sp
12+
Fn3$mcBIDF$sp
13+
Fn3
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Fn[@specialized(Int, AnyRef) -T, @specialized(Int, AnyRef) +R] {
2+
override def toString = getClass.getName
3+
}
4+
5+
class Fn3[
6+
@specialized(Int, AnyRef) -T1,
7+
@specialized(Double, AnyRef) -T2,
8+
@specialized(Float) -T3,
9+
@specialized(Byte, AnyRef) +R
10+
] {
11+
override def toString = getClass.getName
12+
}
13+
14+
object Test {
15+
def main(args: Array[String]): Unit = {
16+
println(new Fn[Int, Int])
17+
println(new Fn[Int, Byte])
18+
println(new Fn[Int, AnyRef])
19+
println(new Fn[Byte, Int])
20+
println(new Fn[Byte, Byte])
21+
println(new Fn[Byte, AnyRef])
22+
println(new Fn[AnyRef, Int])
23+
println(new Fn[AnyRef, Byte])
24+
println(new Fn[AnyRef, AnyRef])
25+
26+
println(new Fn3[Int, Int, Int, Int])
27+
println(new Fn3[Int, Double, Float, Int])
28+
println(new Fn3[Int, Double, Float, Byte])
29+
println(new Fn3[AnyRef, Double, AnyRef, Int])
30+
}
31+
}

0 commit comments

Comments
 (0)