Skip to content

Commit

Permalink
fix: Try fix weak reference tests under lto=thin (#3865)
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Apr 3, 2024
1 parent 01d9752 commit 658a273
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ class WeakReferenceTest {
)
}

@noinline def allocWeakRef(
@nooptimize @noinline def allocWeakRef(
referenceQueue: ReferenceQueue[A]
): WeakReference[A] = {
var a = A()
val weakRef = new WeakReference(a, referenceQueue)
assertEquals("get() should return object reference", weakRef.get(), A())
assertEquals("get() should return object reference", weakRef.get(), a)
a = null
weakRef
}

@noinline def allocSubclassedWeakRef(
@nooptimize @noinline def allocSubclassedWeakRef(
referenceQueue: ReferenceQueue[A]
): SubclassedWeakRef[A] = {
var a = A()
val weakRef = new SubclassedWeakRef(a, referenceQueue)
assertEquals("get() should return object reference", weakRef.get(), A())
assertEquals("get() should return object reference", weakRef.get(), a)
a = null
weakRef
}
Expand All @@ -54,7 +54,7 @@ class WeakReferenceTest {
sys.env.contains("CI") && Platform.isWindows
)

def assertEventuallyIsCollected(
@noinline def assertEventuallyIsCollected(
clue: String,
ref: WeakReference[_],
deadline: Long
Expand All @@ -74,8 +74,8 @@ class WeakReferenceTest {
locally {
val _ = Seq.fill(1000)(new Object {})
}
Thread.sleep(200)
System.gc()
Thread.sleep(200)
assertEventuallyIsCollected(clue, ref, deadline)
} else {
fail(
Expand Down

0 comments on commit 658a273

Please sign in to comment.