diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-08-26 09:21:38 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-30 19:24:04 +0200 |
commit | 92d1af11b04b4f7c8aafd4ff911bf747eb1029aa (patch) | |
tree | 097ee110e9c5a6a20a76469874cf8c26427a847b /test | |
parent | f12e6257eef36ffaa9e2a72afc3f83f59296bf67 (diff) | |
download | scala-92d1af11b04b4f7c8aafd4ff911bf747eb1029aa.tar.gz scala-92d1af11b04b4f7c8aafd4ff911bf747eb1029aa.tar.bz2 scala-92d1af11b04b4f7c8aafd4ff911bf747eb1029aa.zip |
Specialize erasure of `synchronized` primitive method
The goal is to avoid emitting unneeded `BoxedUnit` values,
which are the result of adapting a `Unit`-typed expression
inside a `synchronized(...)` to the erased type of
`synchronized`'s argument -- `Object`.
The proposed solution gives `synchronized` a polymorphic
type (the info of the type param is still erased so that
bounds checking works in the erased type system), so that
an application `synchronized(println("boo"))` erases to
`synchronized[Unit])(println("boo"))`, and no boxing is
performed on the `println("boo")` argument, whose expected
type is now `Unit` instead of `Object`.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/delambdafy_t6028.check | 10 | ||||
-rw-r--r-- | test/files/run/t6028.check | 10 |
2 files changed, 4 insertions, 16 deletions
diff --git a/test/files/run/delambdafy_t6028.check b/test/files/run/delambdafy_t6028.check index 7bd68c78e9..eaba70ee1a 100644 --- a/test/files/run/delambdafy_t6028.check +++ b/test/files/run/delambdafy_t6028.check @@ -44,14 +44,8 @@ package <empty> { }; final <stable> private[this] def MethodLocalObject$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - { - T.this.synchronized({ - if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); - scala.runtime.BoxedUnit.UNIT - }); - () - }; + T.this.synchronized[Unit](if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1)); MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() }; final <artifact> private[this] def $anonfun$tryy$1(tryyParam$1: String, tryyLocal$1: runtime.ObjectRef): Unit = try { diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index f757bc93ff..d6cc452bbf 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -56,14 +56,8 @@ package <empty> { }; final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - { - T.this.synchronized({ - if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); - scala.runtime.BoxedUnit.UNIT - }); - () - }; + T.this.synchronized[Unit](if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1)); MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() }; @SerialVersionUID(value = 0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { |