Skip to content

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

Closed

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

Activity

  1. changed the title [-]Impossible to call overrided `protected internal` method of base class.[/-] [+]Impossible to call overridden `protected internal` method of base class.[/+] on Aug 23, 2018
  2. added
    Issue-Enhancement
    WG-Language
    on Aug 24, 2018
  3. iSazonov commented on Aug 24, 2018

    @iSazonov
    Collaborator

    /cc Rob Holt (@rjmholt) maybe add to #6652?

  4. rjmholt commented on Aug 24, 2018

    @rjmholt
    Collaborator

    Yuriy Kushnir (@yurko7) By "overridden implementation called recursively", I'm guessing you get a StackOverflowException? Can you please paste into the issue description the exact output when the method is called?

  5. yurko7 commented on Aug 24, 2018

    @yurko7
    ContributorAuthor

    Rob Holt (@rjmholt)

    I'm guessing you get a StackOverflowException?

    Depends on implementation of overridden method. On unconditional call of base method, sure, we'll get a StackOverflowException.
    Updated the issue description with exact output.

  6. rjmholt commented on Aug 24, 2018

    @rjmholt
    Collaborator

    Yes, I would imagine it depends on the particular method. I just meant for the example class you specify in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementResolution-FixedWG-Language

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions