Skip to content

Commit 9ef70dd

Browse files
committed
Change backend to handle polymorphic synchronized calls
1 parent 34af0ce commit 9ef70dd

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
254254

255255
BOOL
256256
}
257-
else if (code == SYNCHRONIZED)
258-
genSynchronized(tree, expectedType)
259257
else if (isCoercion(code)) {
260258
genLoad(receiver)
261259
lineNumber(tree)
@@ -714,8 +712,9 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
714712
generatedType = toTypeKind(c.typeValue)
715713
mkArrayConstructorCall(generatedType.asArrayBType, app, dims)
716714
case Apply(t :TypeApply, _) =>
717-
718-
generatedType = genTypeApply(t)
715+
generatedType =
716+
if (t.symbol ne Object_synchronized) genTypeApply(t)
717+
else genSynchronized(app, expectedType)
719718

720719
// 'super' call: Note: since constructors are supposed to
721720
// return an instance of what they construct, we have to take

src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
2828
abstract class SyncAndTryBuilder(cunit: CompilationUnit) extends PlainBodyBuilder(cunit) {
2929

3030
def genSynchronized(tree: Apply, expectedType: BType): BType = tree match {
31-
case Apply(fun, args) =>
31+
case Apply(TypeApply(fun, _), args) =>
3232
val monitor = locals.makeLocal(ObjectReference, "monitor", Object_Type, tree.pos)
3333
val monCleanup = new asm.Label
3434

src/compiler/scala/tools/nsc/backend/jvm/BackendInterface.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ abstract class BackendInterfaceDefinitions { self: BackendInterface =>
697697
val ObjectClass: Symbol
698698
val Object_isInstanceOf: Symbol
699699
val Object_asInstanceOf: Symbol
700+
val Object_synchronized: Symbol
700701
val Object_equals: Symbol
701702
val ArrayClass: Symbol
702703

0 commit comments

Comments
 (0)