diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index 34678befd7e3e..b53ececc2c9b8 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -8165,4 +8165,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
The pattern is too complex to analyze for redundancy.
-
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
index 07f6a8d1b946d..deaa35f37dc0c 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
@@ -2434,6 +2434,8 @@ internal enum ErrorCode
WRN_RedundantPattern = 9336,
HDN_RedundantPatternStackGuard = 9337,
+ ERR_BadVisBaseType = 9338,
+
// Note: you will need to do the following after adding errors:
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)
// 2) Add message to CSharpResources.resx
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
index a2f9c7e5f2faa..f0bbf2ea69e02 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
@@ -2542,6 +2542,7 @@ or ErrorCode.ERR_ExplicitInterfaceMemberReturnTypeMismatch
or ErrorCode.HDN_RedundantPattern
or ErrorCode.WRN_RedundantPattern
or ErrorCode.HDN_RedundantPatternStackGuard
+ or ErrorCode.ERR_BadVisBaseType
=> false,
};
#pragma warning restore CS8524 // The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value.
diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs
index c162b2e0b9415..a6b232d26e754 100644
--- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs
+++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs
@@ -386,10 +386,19 @@ static bool containsOnlyOblivious(TypeSymbol type)
diagnostics.Add(ErrorCode.ERR_StaticBaseClass, baseTypeLocation, baseType, this);
}
- if (!this.IsNoMoreVisibleThan(baseType, ref useSiteInfo))
+ if (baseType.FindTypeLessVisibleThan(this, ref useSiteInfo) is { } lessVisibleType)
{
- // Inconsistent accessibility: base class '{1}' is less accessible than class '{0}'
- diagnostics.Add(ErrorCode.ERR_BadVisBaseClass, baseTypeLocation, this, baseType);
+ if (ReferenceEquals(baseType, lessVisibleType))
+ {
+ // Inconsistent accessibility: base class '{1}' is less accessible than class '{0}'
+ diagnostics.Add(ErrorCode.ERR_BadVisBaseClass, baseTypeLocation, this, lessVisibleType);
+ }
+ else
+ {
+ // Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ var lessVisibleTypeLocation = lessVisibleType.GetFirstLocation();
+ diagnostics.Add(ErrorCode.ERR_BadVisBaseType, baseTypeLocation, this, lessVisibleType);
+ }
}
if (baseType.HasFileLocalTypes() && !this.HasFileLocalTypes())
diff --git a/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs b/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
index d0735e63504f7..ea2a93abf3f50 100644
--- a/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
+++ b/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
@@ -672,6 +672,11 @@ public static SpecialType GetSpecialTypeSafe(this TypeSymbol? type)
}
public static bool IsAtLeastAsVisibleAs(this TypeSymbol type, Symbol sym, ref CompoundUseSiteInfo useSiteInfo)
+ {
+ return type.FindTypeLessVisibleThan(sym, ref useSiteInfo) is null;
+ }
+
+ public static TypeSymbol? FindTypeLessVisibleThan(this TypeSymbol type, Symbol sym, ref CompoundUseSiteInfo useSiteInfo)
{
var visitTypeData = s_visitTypeDataPool.Allocate();
@@ -685,7 +690,7 @@ public static bool IsAtLeastAsVisibleAs(this TypeSymbol type, Symbol sym, ref Co
canDigThroughNullable: true); // System.Nullable is public
useSiteInfo = visitTypeData.UseSiteInfo;
- return result is null;
+ return result;
}
finally
{
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
index f65ce130d484d..30b917acea612 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
@@ -357,6 +357,11 @@
Typ {0} není platný pro using static. Lze použít pouze třídu, strukturu, rozhraní, výčet, delegáta nebo obor názvů.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockV bloku unsafe nejde použít příkaz yield return.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
index 95b1c9e02d3a9..18411c2abd606 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
@@ -357,6 +357,11 @@
Der Typ "{0}" ist für "using static" ungültig. Nur eine Klasse, Struktur, Schnittstelle, Enumeration, ein Delegat oder ein Namespace kann verwendet werden.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' block„yield return“ kann nicht in einem „unsicheren“ Block verwendet werden.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
index 4c056d39dc02c..969dcc0de6bc6 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
@@ -357,6 +357,11 @@
El tipo '{0}' no es válido para 'using static'. Solo se puede usar una clase, estructura, interfaz, enumeración, delegado o espacio de nombres.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockNo se puede usar "yield return" en un bloque "unsafe"
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
index 25fd4ece57692..0d9907444e880 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
@@ -357,6 +357,11 @@
Le type '{0}' n'est pas valide pour 'en utilisant statique'. Seuls une classe, une structure, une interface, une énumération, un délégué ou un espace de noms peuvent être utilisés.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockDésolé... Nous ne pouvons pas utiliser « yield return » dans un bloc « unsafe »
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
index 6c72394ce1fef..5d757c9297213 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
@@ -357,6 +357,11 @@
'{0}' tipo non valido per 'using static'. È possibile usare solo una classe, una struttura, un'interfaccia, un'enumerazione, un delegato o uno spazio dei nomi.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockNon è possibile usare 'yield return' in un blocco 'unsafe'
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
index d5b232e38e171..ebcbc0effa379 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
@@ -357,6 +357,11 @@
'{0}' 型は 'using static' では無効です。使用できるのは、クラス、構造体、インターフェイス、列挙型、デリゲート、名前空間のみです。
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' block'unsafe' ブロックでは 'yield return' を使用できません
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
index e77a168ebe867..5d6e6a0aa679b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
@@ -357,6 +357,11 @@
'{0}' 유형은 '정적 사용'에 유효하지 않습니다. 클래스, 구조체, 인터페이스, 열거형, 대리자 또는 네임스페이스만 사용할 수 있습니다.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' block'unsafe' 블록에서 'yield return'을 사용할 수 없습니다.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
index 1c305f6830347..3160885d4a70b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
@@ -357,6 +357,11 @@
Typ „{0}” jest nieprawidłowy dla „using static”. Można używać tylko klasy, struktury, interfejsu, wyliczenia, delegata lub przestrzeni nazw.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockNie można użyć instrukcji „yield return” w bloku „unsafe”
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
index 3bb924654bc71..5cac5a6889b27 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
@@ -357,6 +357,11 @@
'{0}' tipo não é válido para 'using static'. Somente uma classe, struct, interface, enumeração, delegado ou namespace podem ser usados.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockNão é possível usar "yield return" em um bloco "unsafe"
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
index c5b8d18fe64ec..cb95f74721abc 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
@@ -357,6 +357,11 @@
' {0} ' недопустим для 'использования статики'. Можно использовать только класс, структуру, интерфейс, перечисление, делегат или пространство имен.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' blockНевозможно использовать "yield return" в блоке "unsafe".
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
index bd18e7596c70b..67495122974e0 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
@@ -357,6 +357,11 @@
'{0}' türü 'using static' için geçerli değil. Yalnızca bir sınıf, yapı, arabirim, sabit liste, temsilci veya ad alanı kullanılabilir.
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' block'güvenli yield return' bloğunda 'yield return' kullanılamadı
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
index 90b2836f06871..3ad4ad5d0618f 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
@@ -357,6 +357,11 @@
“{0}”类型对于 "using static" 无效。只能使用类、结构、接口、枚举、委托或命名空间。
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' block不能在 "unsafe" 块中使用 "yield return"
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
index 600bdbf066150..fc33d4373c713 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
@@ -357,6 +357,11 @@
'{0}' 類型對 'using static' 無效。只能使用類別、結構、介面、列舉、委派或命名空間。
+
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+ Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
+
+ Cannot use 'yield return' in an 'unsafe' block無法在 'unsafe' 區塊中使用 'yield return'
diff --git a/src/Compilers/CSharp/Test/Emit3/Semantics/RecordTests.cs b/src/Compilers/CSharp/Test/Emit3/Semantics/RecordTests.cs
index cc001d58ca554..f704ed0086a7e 100644
--- a/src/Compilers/CSharp/Test/Emit3/Semantics/RecordTests.cs
+++ b/src/Compilers/CSharp/Test/Emit3/Semantics/RecordTests.cs
@@ -25777,9 +25777,9 @@ public record E { }
if (c.Assembly.RuntimeSupportsCovariantReturnsOfClasses)
{
c.VerifyDiagnostics(
- // (8,12): error CS0060: Inconsistent accessibility: base type 'X' is less accessible than class 'B.C'
+ // (8,12): error CS9338: Inconsistent accessibility: type 'B.C.D' is less accessible than class 'B.C'
// record C : X
- Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("B.C", "X").WithLocation(8, 12),
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("B.C", "B.C.D").WithLocation(8, 12),
// (8,12): error CS0051: Inconsistent accessibility: parameter type 'X' is less accessible than method 'B.C.Equals(X?)'
// record C : X
Diagnostic(ErrorCode.ERR_BadVisParamType, "C").WithArguments("B.C.Equals(X?)", "X").WithLocation(8, 12)
@@ -25788,9 +25788,9 @@ public record E { }
else
{
c.VerifyDiagnostics(
- // (8,12): error CS0060: Inconsistent accessibility: base type 'X' is less accessible than class 'B.C'
+ // (8,12): error CS9338: Inconsistant accessibility: type 'B.C.D' is less accessible than class 'B.C'
// record C : X
- Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("B.C", "X").WithLocation(8, 12),
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("B.C", "B.C.D").WithLocation(8, 12),
// (8,12): error CS0050: Inconsistent accessibility: return type 'X' is less accessible than method 'B.C.$()'
// record C : X
Diagnostic(ErrorCode.ERR_BadVisReturnType, "C").WithArguments("B.C.$()", "X").WithLocation(8, 12),
diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/AccessCheckTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/AccessCheckTests.cs
index 0efdcad68676c..050d89f40a991 100644
--- a/src/Compilers/CSharp/Test/Semantic/Semantics/AccessCheckTests.cs
+++ b/src/Compilers/CSharp/Test/Semantic/Semantics/AccessCheckTests.cs
@@ -429,9 +429,9 @@ public class E { }
");
c.VerifyDiagnostics(
- // (8,11): error CS0060: Inconsistent accessibility: base type 'X' is less accessible than class 'B.C'
+ // (8,11): error CS9338: Inconsistent accessibility: type 'B.C.D' is less accessible than class 'B.C'
// class C : X
- Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("B.C", "X").WithLocation(8, 11));
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("B.C", "B.C.D").WithLocation(8, 11));
}
[Fact]
@@ -593,9 +593,9 @@ public class E { }
");
c.VerifyDiagnostics(
- // (8,11): error CS0060: Inconsistent accessibility: base type 'X' is less accessible than class 'B.C'
+ // (8,11): error CS9338: Inconsistent accessibility: type 'B.C.D' is less accessible than class 'B.C'
// class C : X
- Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("B.C", "X").WithLocation(8, 11));
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("B.C", "B.C.D").WithLocation(8, 11));
}
[Fact]
diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs
index 3c2db5bf9e99e..f24f5c1d4cd8c 100644
--- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs
+++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs
@@ -337,9 +337,9 @@ public class E : C.X { }
}";
var comp = CreateCompilation(text);
comp.VerifyDiagnostics(
- // (16,22): error CS0060: Inconsistent accessibility: base type 'A.B.C.X' is less accessible than class 'F.D.E'
+ // (16,22): error CS9338: Inconsistent accessibility: type 'A.B.C' is less accessible than class 'F.D.E'
// public class E : C.X { }
- Diagnostic(ErrorCode.ERR_BadVisBaseClass, "E").WithArguments("F.D.E", "A.B.C.X")
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "E").WithArguments("F.D.E", "A.B.C")
);
}
@@ -2408,5 +2408,81 @@ class A : I>
// class A : I>
Diagnostic(ErrorCode.ERR_CircularBase, "B").WithArguments("A", "A").WithLocation(4, 41));
}
+
+ [Fact]
+ public void TestBadBaseClassVisibility()
+ {
+ var source = @"
+class A { }
+public class B : A { }";
+
+ var comp = CreateCompilation(source);
+ comp.VerifyDiagnostics(
+ // (2,14): error CS0060: Inconsistent accessibility: base class 'A' is less accessible than class 'B'
+ // public class B : A { }
+ Diagnostic(ErrorCode.ERR_BadVisBaseClass, "B").WithArguments("B", "A").WithLocation(3, 14));
+ }
+
+ [Fact]
+ public void TestBadTypeParameterVisibility()
+ {
+ var source = @"
+class A { }
+public class B { }
+public class C : B { }";
+ var comp = CreateCompilation(source);
+ comp.VerifyDiagnostics(
+ // (4,14): error CS9338: Inconsistent accessibility: type 'A' is less accessible than class 'C'
+ // public class C : B { }
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("C", "A").WithLocation(4, 14));
+ }
+
+ [Fact]
+ public void TestBadContainedTypeVisibility()
+ {
+ var source = @"
+public class A { internal class B { } }
+public class C : A.B { }";
+
+ var comp = CreateCompilation(source);
+ comp.VerifyDiagnostics(
+ // (3,14): error CS0060: Inconsistent accessibility: base class 'A.B' is less accessible than class 'C'
+ // public class C : A.B { }
+ Diagnostic(ErrorCode.ERR_BadVisBaseClass, "C").WithArguments("C", "A.B").WithLocation(3, 14));
+ }
+
+ [Fact]
+ public void TestBadContainingTypeVisibility()
+ {
+ var source = @"
+class A { public class B { } }
+public class C : A.B { }";
+
+ var comp = CreateCompilation(source);
+ comp.VerifyDiagnostics(
+ // (3,14): error CS9338: Inconsistent accessibility: type 'A' is less accessible than class 'C'
+ // public class C : A.B { }
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("C", "A").WithLocation(3, 14));
+ }
+
+ [Fact]
+ public void TestBadContainingTypeVisibilityWithoutExplicitReference()
+ {
+ var source = @"
+using static A;
+
+static class A
+{
+ public class B { }
+}
+
+public class C : B { }";
+
+ var comp = CreateCompilation(source);
+ comp.VerifyDiagnostics(
+ // (9,14): error CS9338: Inconsistent accessibility: type 'A' is less accessible than class 'C'
+ // public class C : B { }
+ Diagnostic(ErrorCode.ERR_BadVisBaseType, "C").WithArguments("C", "A").WithLocation(9, 14));
+ }
}
}
diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs
index 9c279b9a2e8f6..5e7eb5affeea3 100644
--- a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs
+++ b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs
@@ -636,7 +636,7 @@ protected class D { }
}
";
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
- new ErrorDescription { Code = (int)ErrorCode.ERR_BadVisBaseClass, Line = 4, Column = 18 });
+ new ErrorDescription { Code = (int)ErrorCode.ERR_BadVisBaseType, Line = 4, Column = 18 });
}
[WorkItem(539512, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539512")]
@@ -681,7 +681,7 @@ private class C { }
}
";
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
- new ErrorDescription { Code = (int)ErrorCode.ERR_BadVisBaseClass, Line = 4, Column = 19 });
+ new ErrorDescription { Code = (int)ErrorCode.ERR_BadVisBaseType, Line = 4, Column = 19 });
}
[WorkItem(539562, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539562")]
@@ -739,14 +739,14 @@ public class C2 : B