diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts
index 7252a9f0c1d..1b412198e5e 100644
--- a/src/compiler/factory.ts
+++ b/src/compiler/factory.ts
@@ -3941,11 +3941,10 @@ namespace ts {
return recreateOuterExpressions(expression, mutableCall, OuterExpressionKinds.PartiallyEmittedExpressions);
}
}
- else {
- const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind;
- if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) {
- return setTextRange(createParen(expression), expression);
- }
+
+ const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind;
+ if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) {
+ return setTextRange(createParen(expression), expression);
}
return expression;
diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.js b/tests/baselines/reference/propertyAccessOnObjectLiteral.js
new file mode 100644
index 00000000000..4f1f8b042c9
--- /dev/null
+++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.js
@@ -0,0 +1,20 @@
+//// [propertyAccessOnObjectLiteral.ts]
+class A { }
+
+({}).toString();
+
+(() => {
+ ({}).toString();
+})();
+
+
+//// [propertyAccessOnObjectLiteral.js]
+var A = /** @class */ (function () {
+ function A() {
+ }
+ return A;
+}());
+({}.toString());
+(function () {
+ ({}.toString());
+})();
diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.symbols b/tests/baselines/reference/propertyAccessOnObjectLiteral.symbols
new file mode 100644
index 00000000000..5d4dff2dbce
--- /dev/null
+++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.symbols
@@ -0,0 +1,17 @@
+=== tests/cases/compiler/propertyAccessOnObjectLiteral.ts ===
+class A { }
+>A : Symbol(A, Decl(propertyAccessOnObjectLiteral.ts, 0, 0))
+
+({}).toString();
+>({}).toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
+>A : Symbol(A, Decl(propertyAccessOnObjectLiteral.ts, 0, 0))
+>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
+
+(() => {
+ ({}).toString();
+>({}).toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
+>A : Symbol(A, Decl(propertyAccessOnObjectLiteral.ts, 0, 0))
+>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
+
+})();
+
diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.types b/tests/baselines/reference/propertyAccessOnObjectLiteral.types
new file mode 100644
index 00000000000..6d12af799c8
--- /dev/null
+++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.types
@@ -0,0 +1,29 @@
+=== tests/cases/compiler/propertyAccessOnObjectLiteral.ts ===
+class A { }
+>A : A
+
+({}).toString();
+>({}).toString() : string
+>({}).toString : () => string
+>({}) : A
+>{} : A
+>A : A
+>{} : {}
+>toString : () => string
+
+(() => {
+>(() => { ({}).toString();})() : void
+>(() => { ({}).toString();}) : () => void
+>() => { ({}).toString();} : () => void
+
+ ({}).toString();
+>({}).toString() : string
+>({}).toString : () => string
+>({}) : A
+>{} : A
+>A : A
+>{} : {}
+>toString : () => string
+
+})();
+
diff --git a/tests/cases/compiler/propertyAccessOnObjectLiteral.ts b/tests/cases/compiler/propertyAccessOnObjectLiteral.ts
new file mode 100644
index 00000000000..89f4021e04b
--- /dev/null
+++ b/tests/cases/compiler/propertyAccessOnObjectLiteral.ts
@@ -0,0 +1,7 @@
+class A { }
+
+({}).toString();
+
+(() => {
+ ({}).toString();
+})();