Skip to content

Curiously recurring pattern when abstracted through interfaces does not work #55361

@davidwrighton

Description

@davidwrighton

Description

The following application when loaded using .NET 6.0 does not function. In particular, it will spin forever, and not finish.

using System;
using System.Collections.Generic;
using System.Collections;

namespace CuriouslyRecurringPatternThroughInterface
{
    interface IGeneric<T_IGeneric>
    {
    }
    interface ICuriouslyRecurring<T_ICuriouslyRecurring> : IGeneric<CuriouslyRecurringThroughInterface<T_ICuriouslyRecurring>>
    {
    }
    class CuriouslyRecurringThroughInterface<T_CuriouslyRecurringThroughInterface> : ICuriouslyRecurring<T_CuriouslyRecurringThroughInterface>
    {
    }

    class Program
    {
        static object _o;
        static int Main(string[] args)
        {
            // Test that the a generic using a variant of the curiously recurring pattern involving an interface can be loaded.
            _o = typeof(CuriouslyRecurringThroughInterface<int>);
            return 100;
        }
    }
}

Configuration

.NET 6, after PR #54588

Regression?

Yes.

Metadata

Metadata

Assignees

Labels

untriagedNew issue has not been triaged by the area owner

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions