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

File types emit #61646

Merged
merged 14 commits into from
Jun 29, 2022
Merged

File types emit #61646

merged 14 commits into from
Jun 29, 2022

Conversation

RikkiGibson
Copy link
Contributor

@RikkiGibson RikkiGibson commented Jun 1, 2022

Related to #60819

This primarily does the name mangling. In this PR I chose the format <ContainingFileName>F0__OriginalTypeName. We do name mangling through the same mechanism which adds `1 suffixes to generic type names.

@RikkiGibson RikkiGibson force-pushed the ft-emit branch 3 times, most recently from 3d9a8ac to 9a1c962 Compare June 2, 2022 23:38
@RikkiGibson RikkiGibson marked this pull request as ready for review June 3, 2022 18:45
@RikkiGibson RikkiGibson requested a review from a team as a code owner June 3, 2022 18:45
@RikkiGibson RikkiGibson requested review from cston and jcouv June 3, 2022 18:45
tmat
tmat approved these changes Jun 3, 2022
tmat
tmat previously requested changes Jun 3, 2022
Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@tmat

This comment was marked as resolved.

@RikkiGibson
Copy link
Contributor Author

RikkiGibson commented Jun 10, 2022

The EnC tests I've added work fine, but the manual end-to-end test doesn't. A simple edit of an existing method in a file type yields the following diagnostic in the Error List:

Severity	Code	Description	Project	File	Line	Suppression State
Error	ENC1002	Cannot apply changes -- unexpected error: 'Unexpected null - line 676'			1	Active

Will have to look tomorrow to see how to properly triage this. Maybe just attaching a debugger will help :)

edit: addressing this issue in #62215

@RikkiGibson

This comment was marked as resolved.

@@ -326,6 +330,34 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
}

Done:
if (isTopLevel
Copy link
Member

@jcouv jcouv Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that handling lookup for error cases quickly gets complicated :-/ Not blocking this PR, but it would be good to check what Aleksey thinks on supporting "correct" behavior of public APIs in error cases. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that handling lookup for error cases quickly gets complicated :-/ Not blocking this PR, but it would be good to check what Aleksey thinks on supporting "correct" behavior of public APIs in error cases.

It is not clear what specific scenarios we are talking about. Could you please elaborate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlekseyTs The scenario is GetTypeByMetadataName on a nested file-type (class C { file class D { } }), ie. an error scenario.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scenario is GetTypeByMetadataName on a nested file-type (``class C { file class D { } }```), ie. an error scenario.

I think in this case the file modifier on a nested type should be ignored and class D should be treated as a regular nested type. In other words, I think that the best implementation strategy here will be to not have nested file types in the symbol model, under no condition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. That's the approach Rikki took and it makes things simpler. Thanks

@RikkiGibson If we take that approach, let's verify the symbol for class D has !IsFile then.

Copy link
Contributor Author

@RikkiGibson RikkiGibson Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to add an item to test plan and ensure the 'IsFile' API behaves as described here in a subsequent PR.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with review pass (iteration 13)

@jcouv jcouv self-assigned this Jun 28, 2022
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 14)


var types = comp.GetTypesByMetadataName("<>F0__C");
Assert.Equal(2, types.Length);
Assert.Equal(firstIsMetadataReference ? "C@<tree 0>" : "<>F0__C", types[0].ToTestDisplayString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"<>F0__C"

This is not blocking, but it feels strange that display is different

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test plan item

@@ -326,6 +330,35 @@ internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emitted
}

Done:
if (isTopLevel
&& scope is not PENamespaceSymbol
&& (emittedTypeName.ForcedArity == -1 || emittedTypeName.ForcedArity == emittedTypeName.InferredArity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& (emittedTypeName.ForcedArity == -1 || emittedTypeName.ForcedArity == emittedTypeName.InferredArity)

It would be good to have a test backing this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test plan item

@RikkiGibson RikkiGibson mentioned this pull request Jun 29, 2022
83 tasks
@RikkiGibson RikkiGibson merged commit f95472f into dotnet:features/file-types Jun 29, 2022
@RikkiGibson RikkiGibson deleted the ft-emit branch June 29, 2022 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants