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

Check language version for more scenarios #73546

Merged

Conversation

AlekseyTs
Copy link
Contributor

No description provided.

@AlekseyTs AlekseyTs requested review from jjonescz and cston May 17, 2024 17:01
@AlekseyTs AlekseyTs requested a review from a team as a code owner May 17, 2024 17:01
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label May 17, 2024
@AlekseyTs
Copy link
Contributor Author

@cston, @jjonescz, @dotnet/roslyn-compiler Please review

@@ -5853,9 +5853,9 @@ void verify(ModuleSymbol m)
Assert.Equal("I1", s1.InterfacesNoUseSiteDiagnostics().Single().ToTestDisplayString());
}

CreateCompilation(src, targetFramework: TargetFramework.Net80, parseOptions: TestOptions.RegularNext).VerifyDiagnostics();
CreateCompilation(src, targetFramework: TargetFramework.Net70, parseOptions: TestOptions.RegularNext).VerifyDiagnostics();
Copy link
Member

@cston cston May 17, 2024

Choose a reason for hiding this comment

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

TargetFramework.Net70

Was there a reason to change this test to .NET7? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was there a reason to change this test to .NET7?

Just to make the scenario "stronger"

}
";
var comp2 = CreateCompilation(src2, references: [comp1.ToMetadataReference()], targetFramework: s_targetFrameworkSupportingByRefLikeGenerics, parseOptions: TestOptions.Regular12);
comp2.VerifyEmitDiagnostics(
Copy link
Member

@cston cston May 17, 2024

Choose a reason for hiding this comment

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

VerifyEmitDiagnostics

Why do we report an error here for -langversion:12 using IDisposable, but we don't report an error for the -langversion:12 case using IEnumerable<int> in Foreach_IEnumerableT_LanguageVersion_03? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do we report an error here for -langversion:12 using IDisposable, but we don't report an error for the -langversion:12 case using IEnumerable<int> in Foreach_IEnumerableT_LanguageVersion_03?

Semantic analysis didn't rely and still doesn't rely on conversion classification for generic IEnumerable case. I will check behavior in main if it runs into problems elsewhere and will follow up separately, if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides, Foreach_IEnumerableT_LanguageVersion_03 doesn't dispose a ref struct

}
";
var comp2 = CreateCompilation(src2, references: [comp1.ToMetadataReference()], targetFramework: s_targetFrameworkSupportingByRefLikeGenerics, parseOptions: TestOptions.Regular12);
comp2.VerifyEmitDiagnostics();
Copy link
Member

@cston cston May 17, 2024

Choose a reason for hiding this comment

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

comp2.VerifyEmitDiagnostics();

Why does this case succeed but the corresponding -langversion:12 case in Foreach_IEnumerable_LanguageVersion_03 fails? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why does this case succeed but the corresponding -langversion:12 case in Foreach_IEnumerable_LanguageVersion_03 fails?

Semantic analysis didn't rely and still doesn't rely on conversion classification for generic IEnumerable case. I will check behavior in main if it runs into problems elsewhere and will follow up separately, if needed.

static void Main()
{
System.Console.Write((new S() { 200, 40, 6 }).P);
}
Copy link
Member

@cston cston May 17, 2024

Choose a reason for hiding this comment

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

Was the intent to run the code for the success cases? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was the intent to run the code for the success cases?

No. Execution is covered by other tests. I think ObjectCreation_05 in this particular case

@AlekseyTs AlekseyTs requested a review from a team May 17, 2024 20:55
@AlekseyTs
Copy link
Contributor Author

@jjonescz, @dotnet/roslyn-compiler For the second review

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Done review pass. Only a couple of minor questions.

Comment on lines +6164 to +6169
if (needSupportForRefStructInterfaces &&
initializerType.ContainingModule != Compilation.SourceModule)
{
CheckFeatureAvailability(node, MessageID.IDS_FeatureRefStructInterfaces, diagnostics);
}

Copy link
Member

@333fred 333fred May 17, 2024

Choose a reason for hiding this comment

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

Nit: this check is used in several places. Could we consider extracting a helper CheckFeatureAvailabilityForUsage or soemthing similar? #WontFix

}

[Fact]
public void Using_LanguageVersion_04()
Copy link
Member

@333fred 333fred May 17, 2024

Choose a reason for hiding this comment

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

Nit: straight from 2 to 4? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit: straight from 2 to 4?

There is no requirement to avoid gaps in numbers. There is a reason, however, the number matches the other test that covers similar scenario.

}
";

var comp1 = CreateCompilation(src1, targetFramework: s_targetFrameworkSupportingByRefLikeGenerics);
Copy link
Member

@333fred 333fred May 17, 2024

Choose a reason for hiding this comment

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

Why aren't we checking langversion on implementation? Or is that forthcoming? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why aren't we checking langversion on implementation? Or is that forthcoming?

Because this isn't a goal for this PR. I assume you are referring to a scenario covered in ImplementAnInterface_01.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, thanks for clarifying.

}

[Fact]
public void Foreach_IEnumerableT_LanguageVersion_03()
Copy link
Member

@333fred 333fred May 17, 2024

Choose a reason for hiding this comment

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

Nit: straight from 1 to 3? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit: straight from 1 to 3?

Same response

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Done review pass. Only a couple of minor questi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - RefStructInterfaces untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants