Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler fails to detect a constructed file type. #67208

Closed
AlekseyTs opened this issue Mar 7, 2023 · 1 comment · Fixed by #68386
Closed

Compiler fails to detect a constructed file type. #67208

AlekseyTs opened this issue Mar 7, 2023 · 1 comment · Fixed by #68386
Assignees
Milestone

Comments

@AlekseyTs
Copy link
Contributor

file class C1 {}

class C2 : C1 {}

file class C3<T> {}

class C4 : C3<int> {}

Observed:

error CS9053: File-local type 'C1' cannot be used as a base type of non-file-local type 'C2'.

Expected an additional error for base type of C4.

The type is SourceMemberContainerTypeSymbol check is the likely source of the problem:

        public static bool HasFileLocalTypes(this TypeSymbol type)
        {
            var foundType = type.VisitType(predicate: (type, _, _) => type is SourceMemberContainerTypeSymbol { IsFileLocal: true }, arg: (object?)null);
            return foundType is not null;
        }

There are several more places in the code base that might have similar issues.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Mar 7, 2023
@AlekseyTs
Copy link
Contributor Author

CC @RikkiGibson

@RikkiGibson RikkiGibson added this to the 17.6 milestone Mar 7, 2023
@RikkiGibson RikkiGibson self-assigned this Mar 7, 2023
@RikkiGibson RikkiGibson added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 7, 2023
@RikkiGibson RikkiGibson modified the milestones: 17.6, 17.7 May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants