File tree Expand file tree Collapse file tree 4 files changed +10
-13
lines changed
test/dotty/tools/dotc/reporting Expand file tree Collapse file tree 4 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ public enum ErrorMessageID {
104
104
EnumCaseDefinitionInNonEnumOwnerID ,
105
105
ExpectedTypeBoundOrEqualsID ,
106
106
ClassAndCompanionNameClashID ,
107
- TailrecNotApplicableNeitherPrivateNorFinalID ,
107
+ TailrecNotApplicableID ,
108
108
;
109
109
110
110
public int errorNumber () {
Original file line number Diff line number Diff line change @@ -1819,13 +1819,11 @@ object messages {
1819
1819
}
1820
1820
}
1821
1821
1822
- case class TailrecNotApplicableNeitherPrivateNorFinal ( owner : Symbol )(implicit ctx : Context )
1823
- extends Message (TailrecNotApplicableNeitherPrivateNorFinalID ) {
1822
+ case class TailrecNotApplicable ( method : Symbol )(implicit ctx : Context )
1823
+ extends Message (TailrecNotApplicableID ) {
1824
1824
val kind = " Syntax"
1825
- val msg = hl " TailRec optimisation not applicable, ${owner} is neither ` private` nor ` final` so can be overridden "
1825
+ val msg = hl " TailRec optimisation not applicable, $method is neither ${ " private" } nor ${ " final" } . "
1826
1826
val explanation =
1827
- hl """
1828
- |The `@tailrec` annotation can only be used on methods that are either `private` or `final`.
1829
- """
1827
+ hl " A method annotated ${" @tailrec" } must be declared ${" private" } or ${" final" } so it can't be overridden. "
1830
1828
}
1831
1829
}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import Symbols._
12
12
import Types ._
13
13
import NameKinds .TailLabelName
14
14
import TreeTransforms .{MiniPhaseTransform , TransformerInfo }
15
- import reporting .diagnostic .messages .TailrecNotApplicableNeitherPrivateNorFinal
15
+ import reporting .diagnostic .messages .TailrecNotApplicable
16
16
17
17
/**
18
18
* A Tail Rec Transformer
@@ -162,7 +162,7 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
162
162
})
163
163
}
164
164
case d : DefDef if d.symbol.hasAnnotation(defn.TailrecAnnot ) || methodsWithInnerAnnots.contains(d.symbol) =>
165
- ctx.error(TailrecNotApplicableNeitherPrivateNorFinal (sym), sym.pos)
165
+ ctx.error(TailrecNotApplicable (sym), sym.pos)
166
166
d
167
167
case d if d.symbol.hasAnnotation(defn.TailrecAnnot ) || methodsWithInnerAnnots.contains(d.symbol) =>
168
168
ctx.error(" TailRec optimisation not applicable, not a method" , sym.pos)
Original file line number Diff line number Diff line change @@ -1023,22 +1023,21 @@ class ErrorMessagesTests extends ErrorMessagesTest {
1023
1023
assertMessageCount(1 , messages)
1024
1024
val EnumCaseDefinitionInNonEnumOwner (owner) :: Nil = messages
1025
1025
assertEquals(" object Qux" , owner.show)
1026
+ }
1026
1027
1027
1028
@ Test def tailrecNotApplicableNeitherPrivateNorFinal =
1028
1029
checkMessagesAfter(" tailrec" ) {
1029
1030
"""
1030
1031
|class Foo {
1031
- |
1032
1032
| @scala.annotation.tailrec
1033
1033
| def foo: Unit = foo
1034
- |
1035
1034
|}
1036
1035
""" .stripMargin
1037
1036
}.expect { (ictx, messages) =>
1038
1037
implicit val ctx : Context = ictx
1039
1038
assertMessageCount(1 , messages)
1040
- val TailrecNotApplicableNeitherPrivateNorFinal (symbol ) :: Nil = messages
1041
- assertEquals(symbol .show, " method foo" )
1039
+ val TailrecNotApplicable (method ) :: Nil = messages
1040
+ assertEquals(method .show, " method foo" )
1042
1041
}
1043
1042
1044
1043
@ Test def expectedTypeBoundOrEquals =
You can’t perform that action at this time.
0 commit comments