From 48e2da1c0fb387f2d166db54ce5b9c2d75112239 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 4 Dec 2019 22:50:26 -0800 Subject: [PATCH] Fix the class leak --- .../engine/SessionStateScope.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/System.Management.Automation/engine/SessionStateScope.cs b/src/System.Management.Automation/engine/SessionStateScope.cs index b0c1bd3ff4a..a0298746412 100644 --- a/src/System.Management.Automation/engine/SessionStateScope.cs +++ b/src/System.Management.Automation/engine/SessionStateScope.cs @@ -1607,20 +1607,12 @@ internal Language.TypeResolutionState TypeResolutionState { get { - // this is kind of our own lazy initialization logic here. - if (_typeResolutionState == null) + if (_typeResolutionState != null) { - if (this.Parent != null) - { - _typeResolutionState = this.Parent.TypeResolutionState; - } - else - { - _typeResolutionState = Language.TypeResolutionState.UsingSystem; - } + return _typeResolutionState; } - return _typeResolutionState; + return Parent != null ? Parent.TypeResolutionState : Language.TypeResolutionState.UsingSystem; } set { _typeResolutionState = value; }