From de34e3687ff1543c39b9effd44b3f6c85867d624 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 10 Jun 2020 15:45:12 -0700 Subject: [PATCH] Fix diagnostic for mixed partial type (#45025) --- .../CSharp/Portable/CSharpResources.resx | 2 +- .../Portable/xlf/CSharpResources.cs.xlf | 4 ++-- .../Portable/xlf/CSharpResources.de.xlf | 4 ++-- .../Portable/xlf/CSharpResources.es.xlf | 4 ++-- .../Portable/xlf/CSharpResources.fr.xlf | 4 ++-- .../Portable/xlf/CSharpResources.it.xlf | 4 ++-- .../Portable/xlf/CSharpResources.ja.xlf | 4 ++-- .../Portable/xlf/CSharpResources.ko.xlf | 4 ++-- .../Portable/xlf/CSharpResources.pl.xlf | 4 ++-- .../Portable/xlf/CSharpResources.pt-BR.xlf | 4 ++-- .../Portable/xlf/CSharpResources.ru.xlf | 4 ++-- .../Portable/xlf/CSharpResources.tr.xlf | 4 ++-- .../Portable/xlf/CSharpResources.zh-Hans.xlf | 4 ++-- .../Portable/xlf/CSharpResources.zh-Hant.xlf | 4 ++-- .../Test/Semantic/Semantics/RecordTests.cs | 19 +++++++++++++++++++ 15 files changed, 46 insertions(+), 27 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 00aea169c2909..b64620f74470f 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -1087,7 +1087,7 @@ Missing partial modifier on declaration of type '{0}'; another partial declaration of this type exists - Partial declarations of '{0}' must be all classes, all structs, or all interfaces + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces Partial declarations of '{0}' have conflicting accessibility modifiers diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index d339baca09563..04cee0143898b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Částečné deklarace {0} musí být jen třídy, jen struktury, nebo jen rozhraní. + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Částečné deklarace {0} musí být jen třídy, jen struktury, nebo jen rozhraní. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 1552439b04045..57cc7db923c10 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Partielle Deklarationen von "{0}" müssen entweder nur Klassen, nur Strukturen oder nur Schnittstellen sein. + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Partielle Deklarationen von "{0}" müssen entweder nur Klassen, nur Strukturen oder nur Schnittstellen sein. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index d61f03a129ef6..32845482f2608 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Las declaraciones parciales de '{0}' deben ser todas clases, todas estructuras o todas interfaces + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Las declaraciones parciales de '{0}' deben ser todas clases, todas estructuras o todas interfaces diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 667ea00d1d96e..171d754b66ec4 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Les déclarations partielles de '{0}' ne doivent être que des classes, des structs ou des interfaces + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Les déclarations partielles de '{0}' ne doivent être que des classes, des structs ou des interfaces diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index 3f0d635eebba1..f13e34ddd8d4b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Le dichiarazioni parziali di '{0}' devono essere costituite solo da classi, strutture o interfacce + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Le dichiarazioni parziali di '{0}' devono essere costituite solo da classi, strutture o interfacce diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 5b78ac930c82d..4a4686ae35284 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - {0}' の partial 宣言は、すべてのクラス、すべての構造体、またはすべてのインターフェイスにする必要があります。 + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + {0}' の partial 宣言は、すべてのクラス、すべての構造体、またはすべてのインターフェイスにする必要があります。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index a74bf47a91948..b5490d7bd8084 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - {0}'의 partial 선언은 모두 클래스, 구조체 또는 인터페이스여야 합니다. + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + {0}'의 partial 선언은 모두 클래스, 구조체 또는 인터페이스여야 합니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 038da4e608b82..0ab23498d587d 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Wszystkie częściowe deklaracje elementu „{0}” muszą być klasami, strukturami lub interfejsami + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Wszystkie częściowe deklaracje elementu „{0}” muszą być klasami, strukturami lub interfejsami diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index da70e119ffe08..17f75605c1706 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -3558,8 +3558,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Declarações parciais de "{0}" devem ser todas classes, todas as estruturas ou todas as interfaces + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Declarações parciais de "{0}" devem ser todas classes, todas as estruturas ou todas as interfaces diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index efaf778dec6ad..00822f764d245 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - Разделяемые объявления "{0}" должны быть все классами, все структурами или все интерфейсами. + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + Разделяемые объявления "{0}" должны быть все классами, все структурами или все интерфейсами. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index 9dde71c41cb3b..545462da838fb 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - {0}' öğesinin kısmi bildirimlerinin tümü sınıf, tümü yapı ya da tümü arabirim olmalıdır + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + {0}' öğesinin kısmi bildirimlerinin tümü sınıf, tümü yapı ya da tümü arabirim olmalıdır diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index 5b466f39bbb44..a1a78eea1fa90 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - “{0}”的分部声明必须是所有的类、所有的结构或所有的接口 + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + “{0}”的分部声明必须是所有的类、所有的结构或所有的接口 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index 17db03dea6ffa..bded97fba9b1a 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -3560,8 +3560,8 @@ - Partial declarations of '{0}' must be all classes, all structs, or all interfaces - {0}' 的部分宣告必須全部為類別、全部為結構,或全部為介面。 + Partial declarations of '{0}' must be all classes, all records, all structs, or all interfaces + {0}' 的部分宣告必須全部為類別、全部為結構,或全部為介面。 diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs index 9ed43309f63da..9b9f0a48c2340 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs @@ -145,6 +145,25 @@ record Point(int x, int y); comp.VerifyDiagnostics(); } + [Fact] + public void PartialRecordMixedWithClass() + { + var src = @" +partial record C(int X, int Y) +{ +} +partial class C +{ +} +"; + var comp = CreateCompilation(src); + comp.VerifyDiagnostics( + // (5,15): error CS0261: Partial declarations of 'C' must be all classes, all records, all structs, or all interfaces + // partial class C + Diagnostic(ErrorCode.ERR_PartialTypeKindConflict, "C").WithArguments("C").WithLocation(5, 15) + ); + } + [Fact] public void RecordProperties_01() {