File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
test/dotty/tools/dotc/reporting Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1700,7 +1700,7 @@ object Parsers {
1700
1700
def accessQualifierOpt (mods : Modifiers ): Modifiers =
1701
1701
if (in.token == LBRACKET ) {
1702
1702
if ((mods is Local ) || mods.hasPrivateWithin)
1703
- syntaxError(" duplicate private/protected qualifier " )
1703
+ syntaxError(DuplicatePrivateProtectedQualifier () )
1704
1704
inBrackets {
1705
1705
if (in.token == THIS ) { in.nextToken(); mods | Local }
1706
1706
else mods.withPrivateWithin(ident().toTypeName)
Original file line number Diff line number Diff line change @@ -93,7 +93,8 @@ public enum ErrorMessageID {
93
93
ModifiersNotAllowedID ,
94
94
WildcardOnTypeArgumentNotAllowedOnNewID ,
95
95
ImplicitFunctionTypeNeedsNonEmptyParameterListID ,
96
- WrongNumberOfParametersID
96
+ WrongNumberOfParametersID ,
97
+ DuplicatePrivateProtectedQualifierID ,
97
98
;
98
99
99
100
public int errorNumber () {
Original file line number Diff line number Diff line change @@ -1694,4 +1694,12 @@ object messages {
1694
1694
val explanation = " "
1695
1695
}
1696
1696
1697
+ case class DuplicatePrivateProtectedQualifier ()(implicit ctx : Context )
1698
+ extends Message (DuplicatePrivateProtectedQualifierID ) {
1699
+ val kind = " Syntax"
1700
+ val msg = " duplicate private/protected qualifier"
1701
+ val explanation =
1702
+ hl " It is not allowed to combine `private` and `protected` modifiers even if they are qualified to different scopes "
1703
+ }
1704
+
1697
1705
}
Original file line number Diff line number Diff line change @@ -910,4 +910,20 @@ class ErrorMessagesTests extends ErrorMessagesTest {
910
910
911
911
assertEquals(err, WrongNumberOfParameters (1 ))
912
912
}
913
+
914
+ @ Test def duplicatePrivateProtectedQualifier =
915
+ checkMessagesAfter(" frontend" ) {
916
+ """ class Test {
917
+ | private[Test] protected[this] def foo(): Unit = ()
918
+ |} """ .stripMargin
919
+ }
920
+ .expect { (ictx, messages) =>
921
+ implicit val ctx : Context = ictx
922
+ val defn = ictx.definitions
923
+
924
+ assertMessageCount(1 , messages)
925
+ val err :: Nil = messages
926
+
927
+ assertEquals(DuplicatePrivateProtectedQualifier (), err)
928
+ }
913
929
}
You can’t perform that action at this time.
0 commit comments