diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2016-08-09 23:10:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-09 23:10:43 +0200 |
commit | 961c8bea011559af65cfae9818d71ad35b6ecaf4 (patch) | |
tree | 6381d8827907449b5f83e15b3aa0b0f2f25c241c /test | |
parent | 4ba258480607ef937675d606826bb9e418d642cc (diff) | |
parent | 2b1e4efa0a8f30bda7fde8492e8ecfdcbf4801cb (diff) | |
download | scala-961c8bea011559af65cfae9818d71ad35b6ecaf4.tar.gz scala-961c8bea011559af65cfae9818d71ad35b6ecaf4.tar.bz2 scala-961c8bea011559af65cfae9818d71ad35b6ecaf4.zip |
Merge pull request #5290 from lrytz/sd48
SD-48 limit the lenght of inlined local variable names
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala index f531ce9322..f88b95eae4 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala @@ -1587,4 +1587,41 @@ class InlinerTest extends BytecodeTesting { val List(c, t) = compile(code) assertNoIndy(getMethod(c, "t1")) } + + @Test + def limitInlinedLocalVariableNames(): Unit = { + val code = + """class C { + | def f(x: Int): Int = x + | @inline final def methodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | f(param) + | @inline final def anotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | methodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | @inline final def oneMoreMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | anotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | @inline final def yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | oneMoreMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | @inline final def oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | def t(p: Int) = + | oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(p)) + + | oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(p)) + |} + """.stripMargin + + val List(c) = compile(code) + assertEquals(getAsmMethod(c, "t").localVariables.asScala.toList.map(l => (l.name, l.index)).sortBy(_._2),List( + ("this",0), + ("p",1), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence_param",2), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchS_yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFren_param",3), + ("oneLastMethodWithVeryVeryLongNameAlmostLik_yetAnotherMethodWithVeryVeryLongNameAlmost_oneMoreMethodWithVeryVeryLongNameAlmostLik_param",4), + ("oneLastMethodWithVeryVeryLongNam_yetAnotherMethodWithVeryVeryLong_oneMoreMethodWithVeryVeryLongNam_anotherMethodWithVeryVeryLongNam_param",5), + ("oneLastMethodWithVeryVery_yetAnotherMethodWithVeryV_oneMoreMethodWithVeryVery_anotherMethodWithVeryVery_methodWithVeryVeryLongNam_param",6), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence_param",7), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchS_yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFren_param",8), + ("oneLastMethodWithVeryVeryLongNameAlmostLik_yetAnotherMethodWithVeryVeryLongNameAlmost_oneMoreMethodWithVeryVeryLongNameAlmostLik_param",9), + ("oneLastMethodWithVeryVeryLongNam_yetAnotherMethodWithVeryVeryLong_oneMoreMethodWithVeryVeryLongNam_anotherMethodWithVeryVeryLongNam_param",10), + ("oneLastMethodWithVeryVery_yetAnotherMethodWithVeryV_oneMoreMethodWithVeryVery_anotherMethodWithVeryVery_methodWithVeryVeryLongNam_param",11))) + } } |