Skip to content

Impossible to call overridden protected internal method of base class. #7622

@yurko7

Description

@yurko7

Steps to reproduce

Derive from a class with virtual protected internal method. For example, System.Diagnostics.Tracing.EventListener, System.Net.Http.DelegatingHandler.
Override that method.
Call that method of base class.

Add-Type -TypeDefinition @'
    public class BaseMembersTestClass
    {
        protected internal virtual int TestMethod()
        {
            return 1001;
        }
    }
'@
$derived = Invoke-Expression @'
    class BaseCallTestClass : BaseMembersTestClass
    {
        [int] TestMethod()
        {
            return 3 * ([BaseMembersTestClass]$this).TestMethod()
        }
    }

    [BaseCallTestClass]::new()
'@

$derived.TestMethod()

Expected behavior

Method of base class should be called.

Actual behavior

Overridden implementation called recursively until

Process is terminating due to StackOverflowException.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.3
PSEdition                      Core
GitCommitId                    v6.0.3
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.WG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions