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 @@ -102,7 +102,7 @@ public enum ErrorMessageID {
102
102
UncheckedTypePatternID ,
103
103
ExtendFinalClassID ,
104
104
EnumCaseDefinitionInNonEnumOwnerID ,
105
- TailrecNotApplicableNeitherPrivateNorFinalID ,
105
+ TailrecNotApplicableID ,
106
106
;
107
107
108
108
public int errorNumber () {
Original file line number Diff line number Diff line change @@ -1789,13 +1789,11 @@ object messages {
1789
1789
}
1790
1790
1791
1791
1792
- case class TailrecNotApplicableNeitherPrivateNorFinal ( owner : Symbol )(implicit ctx : Context )
1793
- extends Message (TailrecNotApplicableNeitherPrivateNorFinalID ) {
1792
+ case class TailrecNotApplicable ( method : Symbol )(implicit ctx : Context )
1793
+ extends Message (TailrecNotApplicableID ) {
1794
1794
val kind = " Syntax"
1795
- val msg = hl " TailRec optimisation not applicable, ${owner} is neither ` private` nor ` final` so can be overridden "
1795
+ val msg = hl " TailRec optimisation not applicable, $method is neither ${ " private" } nor ${ " final" } . "
1796
1796
val explanation =
1797
- hl """
1798
- |The `@tailrec` annotation can only be used on methods that are either `private` or `final`.
1799
- """
1797
+ hl " A method annotated ${" @tailrec" } must be declared ${" private" } or ${" final" } so it can't be overridden. "
1800
1798
}
1801
1799
}
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
@@ -163,7 +163,7 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
163
163
})
164
164
}
165
165
case d : DefDef if d.symbol.hasAnnotation(defn.TailrecAnnot ) || methodsWithInnerAnnots.contains(d.symbol) =>
166
- ctx.error(TailrecNotApplicableNeitherPrivateNorFinal (sym), sym.pos)
166
+ ctx.error(TailrecNotApplicable (sym), sym.pos)
167
167
d
168
168
case d if d.symbol.hasAnnotation(defn.TailrecAnnot ) || methodsWithInnerAnnots.contains(d.symbol) =>
169
169
ctx.error(" TailRec optimisation not applicable, not a method" , sym.pos)
Original file line number Diff line number Diff line change @@ -1023,21 +1023,20 @@ 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
}
You can’t perform that action at this time.
0 commit comments