Skip to content

Commit a6261ef

Browse files
committed
Merge pull request scala#4603 from lrytz/lambdaSpectest
SI-9373 Restore the test for t8960 with IndyLamba enabled
2 parents 377c2b2 + a1cf489 commit a6261ef

File tree

2 files changed

+78
-72
lines changed

2 files changed

+78
-72
lines changed

test/files/run/t8960.scala

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
object Test extends App {
2+
def testAnonFunClass(o: AnyRef, sp: Boolean = false) = {
3+
val isSpecialized = o.getClass.getSuperclass.getName contains "$sp"
4+
val isDelambdafyMethod = o.getClass.getName contains "$lambda$"
5+
assert(
6+
// delambdafy:method doesn't currently emit specialized anonymous function classes
7+
if (sp) (isSpecialized || isDelambdafyMethod) else !isSpecialized,
8+
o.getClass.getName)
9+
10+
val Some(f) = o.getClass.getDeclaredFields.find(_.getName == "serialVersionUID")
11+
assert(f.getLong(null) == 0l)
12+
}
13+
14+
def testIndyLambda(o: AnyRef, sp: Boolean = false) = {
15+
val isSpecialized = o.getClass.getInterfaces.exists(_.getName contains "$sp")
16+
assert(sp == isSpecialized, o.getClass.getName)
17+
}
18+
19+
20+
testIndyLambda(() => (), sp = true)
21+
testIndyLambda(() => 1, sp = true)
22+
testIndyLambda(() => "")
23+
24+
testIndyLambda((x: Int) => x, sp = true)
25+
testIndyLambda((x: Boolean) => x)
26+
testIndyLambda((x: Int) => "")
27+
28+
testIndyLambda((x1: Int, x2: Int) => 0d, sp = true)
29+
testIndyLambda((x1: Int, x2: AnyRef) => 0d)
30+
testIndyLambda((x1: Any, x2: Any) => x1)
31+
32+
// scala> println((for (i <- 3 to 22) yield (for (j <- 1 to i) yield s"x$j: Int").mkString(" testIndyLambda((", ", ", ") => x1)")).mkString("\n"))
33+
34+
testIndyLambda((x1: Int, x2: Int, x3: Int) => x1)
35+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int) => x1)
36+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1)
37+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1)
38+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1)
39+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1)
40+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1)
41+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1)
42+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1)
43+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1)
44+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1)
45+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1)
46+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1)
47+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1)
48+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1)
49+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1)
50+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1)
51+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1)
52+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1)
53+
testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1)
54+
55+
testAnonFunClass({
56+
case x: Int => x
57+
}: PartialFunction[Int, Int], sp = true)
58+
59+
testAnonFunClass({
60+
case x: Int => x
61+
}: PartialFunction[Any, Any])
62+
63+
testAnonFunClass({
64+
case x: Int => ()
65+
}: PartialFunction[Int, Unit], sp = true)
66+
67+
testAnonFunClass({
68+
case x: String => 1
69+
}: PartialFunction[String, Int])
70+
71+
testAnonFunClass({
72+
case x: String => ()
73+
}: PartialFunction[String, Unit])
74+
75+
testAnonFunClass({
76+
case x: String => x
77+
}: PartialFunction[String, String])
78+
}

test/pending/run/t8960.scala

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)