From d1ccb5caa7844ced54c93f1b29bdcdf91e42bb75 Mon Sep 17 00:00:00 2001 From: "hepin.p" Date: Wed, 27 Apr 2022 13:47:59 +0800 Subject: [PATCH 1/3] =col Clear VectorBuilder more. --- src/library/scala/collection/immutable/Vector.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index df58c35787ce..17968591c553 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -678,6 +678,11 @@ final class VectorBuilder[A]() extends ReusableBuilder[A, Vector[A]] with Vector } def clear(): Unit = { + display5 = null + display4 = null + display3 = null + display2 = null + display1 = null display0 = new Array[AnyRef](32) depth = 1 blockIndex = 0 From 0e4b401913dfe7c94740c3ac592c01591fddccfa Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 1 May 2022 22:55:56 -0700 Subject: [PATCH 2/3] VectorBuilder clear test --- test/junit/scala/collection/immutable/VectorTest.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/junit/scala/collection/immutable/VectorTest.scala b/test/junit/scala/collection/immutable/VectorTest.scala index 69f74872d046..15bd137b7ec6 100644 --- a/test/junit/scala/collection/immutable/VectorTest.scala +++ b/test/junit/scala/collection/immutable/VectorTest.scala @@ -5,6 +5,8 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.tools.testing.AssertUtil._ + @RunWith(classOf[JUnit4]) class VectorTest { @@ -27,4 +29,10 @@ class VectorTest { assertEquals(v, v drop Int.MinValue) assertEquals(v, v dropRight Int.MinValue) } + @Test def `VectorBuilder.clear retains nothing`: Unit = { + val b = new VectorBuilder[Object]() + val x = new Object + for (_ <- 0 to 16384) b += x + assertNotReachable(x, b)(b.clear()) + } } From 9ea62910b53e6d94a77c5761323f09c365a63d36 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 1 May 2022 22:56:55 -0700 Subject: [PATCH 3/3] Reduce warnings --- test/junit/scala/lang/primitives/BoxUnboxTest.scala | 2 ++ test/junit/scala/reflect/internal/NamesTest.scala | 4 +++- .../junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala | 1 - .../scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala | 1 - test/junit/scala/tools/testing/TempDir.scala | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/junit/scala/lang/primitives/BoxUnboxTest.scala b/test/junit/scala/lang/primitives/BoxUnboxTest.scala index 1ec67bddef97..461e960d7ee0 100644 --- a/test/junit/scala/lang/primitives/BoxUnboxTest.scala +++ b/test/junit/scala/lang/primitives/BoxUnboxTest.scala @@ -5,6 +5,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import scala.annotation.nowarn import scala.tools.testing.RunTesting object BoxUnboxTest { @@ -12,6 +13,7 @@ object BoxUnboxTest { } @RunWith(classOf[JUnit4]) +@nowarn("msg=comparing values") class BoxUnboxTest extends RunTesting { @Test diff --git a/test/junit/scala/reflect/internal/NamesTest.scala b/test/junit/scala/reflect/internal/NamesTest.scala index d6182e7cca4f..9bb7f401ef6a 100644 --- a/test/junit/scala/reflect/internal/NamesTest.scala +++ b/test/junit/scala/reflect/internal/NamesTest.scala @@ -1,11 +1,12 @@ package scala.reflect.internal -import scala.tools.testing.AssertUtil._ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test import org.junit.Assert._ +import scala.annotation.nowarn import scala.tools.nsc.symtab.SymbolTableForUnitTesting +import scala.tools.testing.AssertUtil._ @RunWith(classOf[JUnit4]) class NamesTest { @@ -33,6 +34,7 @@ class NamesTest { assertTrue(h1 != f) } + @nowarn("msg=comparing values") @Test def termNamesNotEqualsTypeNames() { assert(h1 ne h1y) diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala index 05df54bc08e6..4e86658c6668 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala @@ -13,7 +13,6 @@ import scala.reflect.internal.util.JavaClearable import scala.tools.asm.tree._ import scala.tools.nsc.backend.jvm.BackendReporting._ import scala.tools.nsc.reporters.StoreReporter -import scala.tools.testing.AssertUtil._ import scala.tools.testing.BytecodeTesting import scala.tools.testing.BytecodeTesting._ diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala index a19e63047c57..57f45399a45e 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala @@ -11,7 +11,6 @@ import scala.collection.JavaConverters._ import scala.tools.asm.Opcodes._ import scala.tools.asm.tree.ClassNode import scala.tools.nsc.backend.jvm.AsmUtils._ -import scala.tools.nsc.reporters.StoreReporter import scala.tools.partest.ASMConverters._ import scala.tools.testing.BytecodeTesting import scala.tools.testing.BytecodeTesting._ diff --git a/test/junit/scala/tools/testing/TempDir.scala b/test/junit/scala/tools/testing/TempDir.scala index c1e4f6376699..d3541455687c 100644 --- a/test/junit/scala/tools/testing/TempDir.scala +++ b/test/junit/scala/tools/testing/TempDir.scala @@ -2,7 +2,7 @@ package scala.tools.testing import java.io.{IOException, File} import java.nio.file.{Path, Files} -import scala.util.{Properties, Try} +import scala.util.Properties import Using.Releasable object TempDir {