Skip to content

Commit cc09bb3

Browse files
committed
@constructorOnly: better error message
This annotation used to be called @transientParam but that's no longer the case.
1 parent 2c3212b commit cc09bb3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ class Definitions {
804804
@tu lazy val TASTYLongSignatureAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.internal.TASTYLongSignature")
805805
@tu lazy val TailrecAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.tailrec")
806806
@tu lazy val ThreadUnsafeAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.threadUnsafe")
807-
@tu lazy val TransientParamAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.constructorOnly")
807+
@tu lazy val ConstructorOnlyAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.constructorOnly")
808808
@tu lazy val CompileTimeOnlyAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.compileTimeOnly")
809809
@tu lazy val SwitchAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.switch")
810810
@tu lazy val ThrowsAnnot: ClassSymbol = ctx.requiredClass("scala.throws")

compiler/src/dotty/tools/dotc/transform/Constructors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
228228
Nil
229229
}
230230
else {
231-
if (acc.hasAnnotation(defn.TransientParamAnnot))
232-
ctx.error(em"transient parameter $acc is retained as field in class ${acc.owner}", acc.sourcePos)
231+
if (acc.hasAnnotation(defn.ConstructorOnlyAnnot))
232+
ctx.error(em"${acc.name} is marked `@constructorOnly` but it is retained as a field in ${acc.owner}", acc.sourcePos)
233233
val target = if (acc.is(Method)) acc.field else acc
234234
if (!target.exists) Nil // this case arises when the parameter accessor is an alias
235235
else {

0 commit comments

Comments
 (0)