Skip to content

Commit bf951ec

Browse files
lrytzadriaanm
authored andcommitted
Fix some tests, move others to pending/
Move run/t8960 to pending It tests the serialVersionUID field on closure classes. The field doesn't exist for indyLambda closures. See https://issues.scala-lang.org/browse/SI-9373 Move some reify tests to pending They fail at runtime in GenBCode since scala is built with indyLambda enabled: java.lang.AssertionError: assertion failed: Bad superClass for trait JFunction1: class Any at scala.tools.nsc.Global.assert(Global.scala:261) at scala.tools.nsc.backend.jvm.BTypesFromSymbols.setClassInfo(BTypesFromSymbols.scala:228) Noted in https://issues.scala-lang.org/browse/SI-9374 force t6546 to GenASM - no closure elimination in GenBCode yet Noted in https://issues.scala-lang.org/browse/SI-9364. Fix or disable some tests that fail because of the old optimizer The old inliner fails more often when the library is built with indylambda. Noted in https://issues.scala-lang.org/browse/SI-9374. Example: List.foreach ➜ sandbox git:(jfun) ✗ qs -Ybackend:GenASM -optimize -Yinline-warnings Welcome to Scala version 2.12.0-20150630-220939-1cb032d806 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). Type in expressions to have them evaluated. Type :help for more information. scala> List(1,2,3).foreach(x => x + 1) <console>:11: warning: Could not inline required method foreach because bytecode unavailable. List(1,2,3).foreach(x => x + 1) ^ <console>:11: warning: At the end of the day, could not inline @inline-marked method foreach List(1,2,3).foreach(x => x + 1) ^ Upate a number of tests for having indyLambda enabled The delambdafyLambdaClassNames tests was removed, there's nothing to tests with indyLambda.
1 parent c58f4e4 commit bf951ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+94
-323
lines changed

test/files/jvm/innerClassAttribute.check

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

test/files/jvm/innerClassAttribute/Classes_1.scala

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -187,41 +187,30 @@ trait A24 extends A24Base {
187187
}
188188

189189
class SI_9105 {
190-
// the EnclosingMethod attributes depend on the delambdafy strategy (inline vs method)
191-
192-
// outerClass-inline enclMeth-inline outerClass-method enclMeth-method
190+
// outerClass enclMeth
193191
val fun = (s: String) => {
194-
class A // closure null (*) SI_9105 null
195-
def m: Object = { class B; new B } // closure m$1 SI_9105 m$1
196-
val f: Object = { class C; new C } // closure null (*) SI_9105 null
192+
class A // SI_9105 null
193+
def m: Object = { class B; new B } // SI_9105 m$1
194+
val f: Object = { class C; new C } // SI_9105 null
197195
}
198196
def met = (s: String) => {
199-
class D // closure null (*) SI_9105 met
200-
def m: Object = { class E; new E } // closure m$1 SI_9105 m$1
201-
val f: Object = { class F; new F } // closure null (*) SI_9105 met
197+
class D // SI_9105 met
198+
def m: Object = { class E; new E } // SI_9105 m$1
199+
val f: Object = { class F; new F } // SI_9105 met
202200
}
203201

204-
// (*) the originalOwner chain of A (similar for D) is: SI_9105.fun.$anonfun-value.A
205-
// we can get to the anonfun-class (created by uncurry), but not to the apply method.
206-
//
207-
// for C and F, the originalOwner chain is fun.$anonfun-value.f.C. at later phases, the rawowner of f is
208-
// an apply$sp method of the closure class. we could use that as enclosing method, but it would be unsystematic
209-
// (A / D don't have an encl meth either), and also strange to use the $sp, which is a compilation artifact.
210-
// So using `null` looks more like the situation in the source code: C / F are nested classes of the anon-fun, and
211-
// there's no method in between.
212-
213202
def byName(op: => Any) = 0
214203

215204
val bnV = byName {
216-
class G // closure null (*) SI_9105 null
217-
def m: Object = { class H; new H } // closure m$1 SI_9105 m$1
218-
val f: Object = { class I; new I } // closure null (*) SI_9105 null
205+
class G // SI_9105 null
206+
def m: Object = { class H; new H } // SI_9105 m$1
207+
val f: Object = { class I; new I } // SI_9105 null
219208
""
220209
}
221210
def bnM = byName {
222-
class J // closure null (*) SI_9105 bnM
223-
def m: Object = { class K; new K } // closure m$1 SI_9105 m$1
224-
val f: Object = { class L; new L } // closure null (*) SI_9105 bnM
211+
class J // SI_9105 bnM
212+
def m: Object = { class K; new K } // SI_9105 m$1
213+
val f: Object = { class L; new L } // SI_9105 bnM
225214
""
226215
}
227216
}

test/files/jvm/innerClassAttribute/Test.scala

Lines changed: 32 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ object Test extends BytecodeTest {
7878
println(s"${e.outerClass} / ${e.name} / ${e.descriptor}")
7979
}
8080

81-
def lambdaClass(anonfunName: String, lambdaName: String): String = {
82-
if (classpath.findClass(anonfunName).isDefined) anonfunName else lambdaName
83-
}
81+
82+
val methodHandlesLookup = assertMember(_: InnerClassNode, "java/lang/invoke/MethodHandles", "Lookup", flags = publicStatic | Flags.ACC_FINAL)
83+
8484

8585
def testA1() = {
8686
val List(b1) = innerClassNodes("A1")
@@ -109,11 +109,7 @@ object Test extends BytecodeTest {
109109
}
110110

111111
def testA4() = {
112-
println("-- A4 --")
113-
printInnerClassNodes("A4")
114-
val fun = lambdaClass("A4$$anonfun$f$1", "A4$lambda$$f$1")
115-
printInnerClassNodes(fun)
116-
printEnclosingMethod(fun)
112+
testInner("A4", methodHandlesLookup)
117113
}
118114

119115
def testA5() = {
@@ -247,47 +243,11 @@ object Test extends BytecodeTest {
247243
}
248244

249245
def testA19() = {
250-
println("-- A19 --")
251-
252-
printInnerClassNodes("A19")
253-
254-
val fun1 = lambdaClass("A19$$anonfun$1", "A19$lambda$1")
255-
val fun2 = lambdaClass("A19$$anonfun$2", "A19$lambda$2")
256-
val fun3 = lambdaClass("A19$$anonfun$3", "A19$lambda$3")
257-
258-
printInnerClassNodes(fun1)
259-
printInnerClassNodes(fun2)
260-
printInnerClassNodes(fun3)
261-
262-
printEnclosingMethod(fun1)
263-
printEnclosingMethod(fun2)
264-
printEnclosingMethod(fun3)
246+
testInner("A19", methodHandlesLookup)
265247
}
266248

267249
def testA20() = {
268-
println("-- A20 --")
269-
270-
printInnerClassNodes("A20")
271-
272-
val fun1 = lambdaClass("A20$$anonfun$4", "A20$lambda$1")
273-
val fun2 = lambdaClass("A20$$anonfun$4$$anonfun$apply$1", "A20$lambda$$$nestedInAnonfun$5$1")
274-
val fun3 = lambdaClass("A20$$anonfun$4$$anonfun$apply$2", "A20$lambda$$$nestedInAnonfun$5$2")
275-
val fun4 = lambdaClass("A20$$anonfun$4$$anonfun$apply$2$$anonfun$apply$3", "A20$lambda$$$nestedInAnonfun$7$1")
276-
277-
println("fun1: attribute for itself and the two child closures `() => ()` and `() => () => 1`")
278-
printInnerClassNodes(fun1)
279-
println("fun2 () => (): itself and the outer closure")
280-
printInnerClassNodes(fun2)
281-
println("fun3 () => () => (): itself, the outer closure and its child closure")
282-
printInnerClassNodes(fun3)
283-
println("fun4: () => 1: itself and the two outer closures")
284-
printInnerClassNodes(fun4)
285-
286-
println("enclosing: nested closures have outer class defined, but no outer method")
287-
printEnclosingMethod(fun1)
288-
printEnclosingMethod(fun2)
289-
printEnclosingMethod(fun3)
290-
printEnclosingMethod(fun4)
250+
testInner("A20", methodHandlesLookup)
291251
}
292252

293253
def testA21() = {
@@ -337,70 +297,30 @@ object Test extends BytecodeTest {
337297
}
338298

339299
def testSI_9105() {
340-
val isDelambdafyMethod = classpath.findClass("SI_9105$lambda$1").isDefined
341-
if (isDelambdafyMethod) {
342-
assertEnclosingMethod ("SI_9105$A$3" , "SI_9105", null , null)
343-
assertEnclosingMethod ("SI_9105$B$5" , "SI_9105", "m$1", "()Ljava/lang/Object;")
344-
assertEnclosingMethod ("SI_9105$C$1" , "SI_9105", null , null)
345-
assertEnclosingMethod ("SI_9105$D$1" , "SI_9105", "met", "()Lscala/Function1;")
346-
assertEnclosingMethod ("SI_9105$E$1" , "SI_9105", "m$3", "()Ljava/lang/Object;")
347-
assertEnclosingMethod ("SI_9105$F$1" , "SI_9105", "met", "()Lscala/Function1;")
348-
assertNoEnclosingMethod("SI_9105$lambda$$met$1")
349-
assertNoEnclosingMethod("SI_9105$lambda$1")
350-
assertNoEnclosingMethod("SI_9105")
351-
352-
assertLocal(innerClassNodes("SI_9105$A$3").head, "SI_9105$A$3", "A$3")
353-
assertLocal(innerClassNodes("SI_9105$B$5").head, "SI_9105$B$5", "B$5")
354-
assertLocal(innerClassNodes("SI_9105$C$1").head, "SI_9105$C$1", "C$1")
355-
assertLocal(innerClassNodes("SI_9105$D$1").head, "SI_9105$D$1", "D$1")
356-
assertLocal(innerClassNodes("SI_9105$E$1").head, "SI_9105$E$1", "E$1")
357-
assertLocal(innerClassNodes("SI_9105$F$1").head, "SI_9105$F$1", "F$1")
358-
359-
// by-name
360-
assertEnclosingMethod("SI_9105$G$1", "SI_9105", null , null)
361-
assertEnclosingMethod("SI_9105$H$1", "SI_9105", "m$2", "()Ljava/lang/Object;")
362-
assertEnclosingMethod("SI_9105$I$1", "SI_9105", null , null)
363-
assertEnclosingMethod("SI_9105$J$1", "SI_9105", "bnM", "()I")
364-
assertEnclosingMethod("SI_9105$K$2", "SI_9105", "m$4", "()Ljava/lang/Object;")
365-
assertEnclosingMethod("SI_9105$L$1", "SI_9105", "bnM", "()I")
366-
367-
assert(innerClassNodes("SI_9105$lambda$$met$1").isEmpty)
368-
assert(innerClassNodes("SI_9105$lambda$1").isEmpty)
369-
assert(innerClassNodes("SI_9105").length == 12) // the 12 local classes
370-
} else {
371-
// comment in innerClassAttribute/Classes_1.scala explains the difference between A / C and D / F.
372-
assertEnclosingMethod ("SI_9105$$anonfun$5$A$3" , "SI_9105$$anonfun$5" , null , null)
373-
assertEnclosingMethod ("SI_9105$$anonfun$5$B$5" , "SI_9105$$anonfun$5" , "m$1" , "()Ljava/lang/Object;")
374-
assertEnclosingMethod ("SI_9105$$anonfun$5$C$1" , "SI_9105$$anonfun$5" , null , null)
375-
assertEnclosingMethod ("SI_9105$$anonfun$met$1$D$1", "SI_9105$$anonfun$met$1", null , null)
376-
assertEnclosingMethod ("SI_9105$$anonfun$met$1$E$1", "SI_9105$$anonfun$met$1", "m$3" , "()Ljava/lang/Object;")
377-
assertEnclosingMethod ("SI_9105$$anonfun$met$1$F$1", "SI_9105$$anonfun$met$1", null , null)
378-
assertEnclosingMethod ("SI_9105$$anonfun$5" , "SI_9105" , null , null)
379-
assertEnclosingMethod ("SI_9105$$anonfun$met$1" , "SI_9105" , "met" , "()Lscala/Function1;")
380-
assertNoEnclosingMethod("SI_9105")
381-
382-
assertLocal(ownInnerClassNode("SI_9105$$anonfun$5$A$3"), "SI_9105$$anonfun$5$A$3" , "A$3")
383-
assertLocal(ownInnerClassNode("SI_9105$$anonfun$5$B$5"), "SI_9105$$anonfun$5$B$5" , "B$5")
384-
assertLocal(ownInnerClassNode("SI_9105$$anonfun$5$C$1"), "SI_9105$$anonfun$5$C$1" , "C$1")
385-
assertLocal(ownInnerClassNode("SI_9105$$anonfun$met$1$D$1"), "SI_9105$$anonfun$met$1$D$1", "D$1")
386-
assertLocal(ownInnerClassNode("SI_9105$$anonfun$met$1$E$1"), "SI_9105$$anonfun$met$1$E$1", "E$1")
387-
assertLocal(ownInnerClassNode("SI_9105$$anonfun$met$1$F$1"), "SI_9105$$anonfun$met$1$F$1", "F$1")
388-
389-
// by-name
390-
assertEnclosingMethod("SI_9105$$anonfun$6$G$1", "SI_9105$$anonfun$6", null, null)
391-
assertEnclosingMethod("SI_9105$$anonfun$6$H$1", "SI_9105$$anonfun$6", "m$2", "()Ljava/lang/Object;")
392-
assertEnclosingMethod("SI_9105$$anonfun$6$I$1", "SI_9105$$anonfun$6", null, null)
393-
assertEnclosingMethod("SI_9105$$anonfun$bnM$1$J$1", "SI_9105$$anonfun$bnM$1", null, null)
394-
assertEnclosingMethod("SI_9105$$anonfun$bnM$1$K$2", "SI_9105$$anonfun$bnM$1", "m$4", "()Ljava/lang/Object;")
395-
assertEnclosingMethod("SI_9105$$anonfun$bnM$1$L$1", "SI_9105$$anonfun$bnM$1", null, null)
396-
397-
assertAnonymous(ownInnerClassNode("SI_9105$$anonfun$5"), "SI_9105$$anonfun$5")
398-
assertAnonymous(ownInnerClassNode("SI_9105$$anonfun$met$1"), "SI_9105$$anonfun$met$1")
399-
400-
assert(innerClassNodes("SI_9105$$anonfun$5").length == 4) // itself and three of the local classes
401-
assert(innerClassNodes("SI_9105$$anonfun$met$1").length == 4) // itself and three of the local classes
402-
assert(innerClassNodes("SI_9105").length == 4) // the four anon funs
403-
}
300+
assertEnclosingMethod ("SI_9105$A$3" , "SI_9105", null , null)
301+
assertEnclosingMethod ("SI_9105$B$5" , "SI_9105", "m$1", "()Ljava/lang/Object;")
302+
assertEnclosingMethod ("SI_9105$C$1" , "SI_9105", null , null)
303+
assertEnclosingMethod ("SI_9105$D$1" , "SI_9105", "met", "()Lscala/Function1;")
304+
assertEnclosingMethod ("SI_9105$E$1" , "SI_9105", "m$3", "()Ljava/lang/Object;")
305+
assertEnclosingMethod ("SI_9105$F$1" , "SI_9105", "met", "()Lscala/Function1;")
306+
assertNoEnclosingMethod("SI_9105")
307+
308+
assertLocal(innerClassNodes("SI_9105$A$3").head, "SI_9105$A$3", "A$3")
309+
assertLocal(innerClassNodes("SI_9105$B$5").head, "SI_9105$B$5", "B$5")
310+
assertLocal(innerClassNodes("SI_9105$C$1").head, "SI_9105$C$1", "C$1")
311+
assertLocal(innerClassNodes("SI_9105$D$1").head, "SI_9105$D$1", "D$1")
312+
assertLocal(innerClassNodes("SI_9105$E$1").head, "SI_9105$E$1", "E$1")
313+
assertLocal(innerClassNodes("SI_9105$F$1").head, "SI_9105$F$1", "F$1")
314+
315+
// by-name
316+
assertEnclosingMethod("SI_9105$G$1", "SI_9105", null , null)
317+
assertEnclosingMethod("SI_9105$H$1", "SI_9105", "m$2", "()Ljava/lang/Object;")
318+
assertEnclosingMethod("SI_9105$I$1", "SI_9105", null , null)
319+
assertEnclosingMethod("SI_9105$J$1", "SI_9105", "bnM", "()I")
320+
assertEnclosingMethod("SI_9105$K$2", "SI_9105", "m$4", "()Ljava/lang/Object;")
321+
assertEnclosingMethod("SI_9105$L$1", "SI_9105", "bnM", "()I")
322+
323+
assert(innerClassNodes("SI_9105").length == 13) // the 12 local classes, plus MethodHandles$Lookup
404324
}
405325

406326
def testSI_9124() {
@@ -530,37 +450,8 @@ object Test extends BytecodeTest {
530450
testInner("NestedInValueClass$A$B", am, b)
531451
testInner("NestedInValueClass$A$C$2", am, c)
532452

533-
val isDelambdafyMethod = classpath.findClass("NestedInValueClass$A$lambda$$f$extension$1").isDefined
534-
if (isDelambdafyMethod) {
535-
List(
536-
"NestedInValueClass$A$lambda$$g$2$1",
537-
"NestedInValueClass$A$lambda$$f$extension$1",
538-
"NestedInValueClass$A$lambda$$$nestedInAnonfun$13$1",
539-
"NestedInValueClass$A$lambda$$NestedInValueClass$A$$$nestedInAnonfun$15$1").foreach(assertNoEnclosingMethod)
540-
testInner("NestedInValueClass$A", a, am)
541-
testInner("NestedInValueClass$A$", a, am, b, c)
542-
testInner("NestedInValueClass$A$lambda$$g$2$1", am)
543-
testInner("NestedInValueClass$A$lambda$$f$extension$1", am)
544-
testInner("NestedInValueClass$A$lambda$$$nestedInAnonfun$13$1", am)
545-
testInner("NestedInValueClass$A$lambda$$NestedInValueClass$A$$$nestedInAnonfun$15$1", am)
546-
} else {
547-
assertEnclosingMethod("NestedInValueClass$A$$anonfun$g$2$1" , "NestedInValueClass$A" , null, null)
548-
assertEnclosingMethod("NestedInValueClass$A$$anonfun$g$2$1$$anonfun$apply$4" , "NestedInValueClass$A$$anonfun$g$2$1" , null, null)
549-
assertEnclosingMethod("NestedInValueClass$A$$anonfun$f$extension$1" , "NestedInValueClass$A" , "f", "()Lscala/collection/immutable/List;")
550-
assertEnclosingMethod("NestedInValueClass$A$$anonfun$f$extension$1$$anonfun$apply$5", "NestedInValueClass$A$$anonfun$f$extension$1", null, null)
551-
552-
val gfun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$g$2$1")
553-
val ffun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$f$extension$1")
554-
val gfunfun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$g$2$1$$anonfun$apply$4")
555-
val ffunfun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$f$extension$1$$anonfun$apply$5")
556-
557-
testInner("NestedInValueClass$A", a, am, ffun, gfun)
558-
testInner("NestedInValueClass$A$", a, am, ffun, gfun, b, c)
559-
testInner("NestedInValueClass$A$$anonfun$g$2$1", a, am, gfun, gfunfun)
560-
testInner("NestedInValueClass$A$$anonfun$g$2$1$$anonfun$apply$4", am, gfun, gfunfun)
561-
testInner("NestedInValueClass$A$$anonfun$f$extension$1", a, am, ffun, ffunfun)
562-
testInner("NestedInValueClass$A$$anonfun$f$extension$1$$anonfun$apply$5", am, ffun, ffunfun)
563-
}
453+
testInner("NestedInValueClass$A", a, am)
454+
testInner("NestedInValueClass$A$", a, am, b, c, methodHandlesLookup)
564455
}
565456

566457
def show(): Unit = {

0 commit comments

Comments
 (0)