diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t7974.check | 23 | ||||
-rw-r--r-- | test/files/run/t7974/Test.scala | 14 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala | 85 |
3 files changed, 95 insertions, 27 deletions
diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check index d8152d3286..4eae5eb152 100644 --- a/test/files/run/t7974.check +++ b/test/files/run/t7974.check @@ -1,19 +1,3 @@ -public class Symbols { - - - - - // access flags 0x12 - private final Lscala/Symbol; someSymbol3 - - // access flags 0xA - private static Lscala/Symbol; symbol$1 - - // access flags 0xA - private static Lscala/Symbol; symbol$2 - - // access flags 0xA - private static Lscala/Symbol; symbol$3 // access flags 0x9 public static <clinit>()V @@ -33,6 +17,7 @@ public class Symbols { MAXSTACK = 2 MAXLOCALS = 0 + // access flags 0x1 public someSymbol1()Lscala/Symbol; GETSTATIC Symbols.symbol$1 : Lscala/Symbol; @@ -40,6 +25,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public someSymbol2()Lscala/Symbol; GETSTATIC Symbols.symbol$2 : Lscala/Symbol; @@ -47,6 +33,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public sameSymbol1()Lscala/Symbol; GETSTATIC Symbols.symbol$1 : Lscala/Symbol; @@ -54,6 +41,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public someSymbol3()Lscala/Symbol; ALOAD 0 @@ -62,6 +50,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public <init>()V ALOAD 0 @@ -72,4 +61,4 @@ public class Symbols { RETURN MAXSTACK = 2 MAXLOCALS = 1 -} + diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala index 29d2b9cb64..296ec32ee2 100644 --- a/test/files/run/t7974/Test.scala +++ b/test/files/run/t7974/Test.scala @@ -1,20 +1,14 @@ -import java.io.PrintWriter; +import java.io.PrintWriter import scala.tools.partest.BytecodeTest +import scala.tools.nsc.backend.jvm.AsmUtils import scala.tools.asm.util._ import scala.tools.nsc.util.stringFromWriter +import scala.collection.convert.decorateAsScala._ object Test extends BytecodeTest { def show { val classNode = loadClassNode("Symbols", skipDebugInfo = true) - val textifier = new Textifier - classNode.accept(new TraceClassVisitor(null, textifier, null)) - - val classString = stringFromWriter(w => textifier.print(w)) - val result = - classString.split('\n') - .dropWhile(elem => elem != "public class Symbols {") - .filterNot(elem => elem.startsWith(" @Lscala/reflect/ScalaSignature") || elem.startsWith(" ATTRIBUTE ScalaSig")) - result foreach println + classNode.methods.asScala.foreach(m => println(AsmUtils.textify(m))) } } diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala new file mode 100644 index 0000000000..f8e887426b --- /dev/null +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala @@ -0,0 +1,85 @@ +package scala.tools.nsc +package backend.jvm +package opt + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test +import scala.tools.asm.Opcodes._ +import org.junit.Assert._ + +import CodeGenTools._ +import scala.tools.nsc.backend.jvm.BTypes.{MethodInlineInfo, InlineInfo} +import scala.tools.partest.ASMConverters +import ASMConverters._ +import scala.collection.convert.decorateAsScala._ + +object ScalaInlineInfoTest { + var compiler = newCompiler(extraArgs = "-Ybackend:GenBCode -Yopt:l:none") + def clear(): Unit = { compiler = null } +} + +@RunWith(classOf[JUnit4]) +class ScalaInlineInfoTest { + val compiler = newCompiler() + + @Test + def traitMembersInlineInfo(): Unit = { + val code = + """trait T { + | def f1 = 1 // concrete method + | private def f2 = 1 // implOnly method (does not end up in the interface) + | def f3 = { + | def nest = 0 // nested method (does not end up in the interface) + | nest + | } + | + | @inline + | def f4 = super.toString // super accessor + | + | object O // module accessor (method is generated) + | def f5 = { + | object L { val x = 0 } // nested module (just flattened out) + | L.x + | } + | + | @noinline + | def f6: Int // abstract method (not in impl class) + | + | // fields + | + | val x1 = 0 + | var y2 = 0 + | var x3: Int + | lazy val x4 = 0 + | + | final val x5 = 0 + |} + """.stripMargin + + val cs @ List(t, tl, to, tCls) = compileClasses(compiler)(code) + val List(info) = t.attrs.asScala.collect({ case a: InlineInfoAttribute => a.inlineInfo }).toList + val expect = InlineInfo( + None, // self type + false, // final class + Map( + ("O()LT$O$;", MethodInlineInfo(true, false,false,false)), + ("T$$super$toString()Ljava/lang/String;",MethodInlineInfo(false,false,false,false)), + ("T$_setter_$x1_$eq(I)V", MethodInlineInfo(false,false,false,false)), + ("f1()I", MethodInlineInfo(false,true, false,false)), + ("f3()I", MethodInlineInfo(false,true, false,false)), + ("f4()Ljava/lang/String;", MethodInlineInfo(false,true, true, false)), + ("f5()I", MethodInlineInfo(false,true, false,false)), + ("f6()I", MethodInlineInfo(false,false,false,true )), + ("x1()I", MethodInlineInfo(false,false,false,false)), + ("x3()I", MethodInlineInfo(false,false,false,false)), + ("x3_$eq(I)V", MethodInlineInfo(false,false,false,false)), + ("x4()I", MethodInlineInfo(false,false,false,false)), + ("x5()I", MethodInlineInfo(true, false,false,false)), + ("y2()I", MethodInlineInfo(false,false,false,false)), + ("y2_$eq(I)V", MethodInlineInfo(false,false,false,false))), + None // warning + ) + assert(info == expect, info) + } +} |