diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 15ec455066..7d67ff991c 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -557,7 +557,7 @@ public function renderVar($arg) {
}
// Optimize for scalars as it is likely they come from the escape filter.
- if (is_scalar($arg) || $arg instanceof MarkupInterface || $arg instanceof \Twig_Markup) {
+ if (is_scalar($arg)) {
return $arg;
}
diff --git a/core/modules/system/src/Tests/Theme/TwigExtensionTest.php b/core/modules/system/src/Tests/Theme/TwigExtensionTest.php
index b2536fa531..4e93eb9251 100644
--- a/core/modules/system/src/Tests/Theme/TwigExtensionTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigExtensionTest.php
@@ -94,7 +94,7 @@ public function testRenderMarkup() {
/** @var \Drupal\Core\Template\TwigExtension $extension */
$extension = \Drupal::service('twig.extension');
$markup = new FormattableMarkup('This is a @markup', ['@markup' => 'MarkupInterface']);
- $this->assertIdentical($extension->renderVar($markup), $markup, 'TwigExtension::renderVar() returns MarkupInterface correctly.');
+ $this->assertIdentical($extension->renderVar($markup), 'This is a MarkupInterface', 'TwigExtension::renderVar() returns MarkupInterface correctly.');
}
}
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
index 8a613c31a0..169f0d4c98 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
@@ -27,9 +27,9 @@ function twig_theme_test_theme($existing, $type, $theme, $path) {
$items['twig_theme_test_trans_render_array'] = array(
'variables' => array(
'var' => array(
- '#prefix' => '',
+ '#prefix' => '',
'#markup' => 'trans render array',
- '#suffix' => '',
+ '#suffix' => '',
),
),
'template' => 'twig_theme_test.trans_render_array',