Skip to content

Commit b345e5a

Browse files
committed
replace warning with error
1 parent 63c8b4c commit b345e5a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

core/src/test/scala/com/avsystem/commons/serialization/NotUsedTransientDefault.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package com.avsystem.commons.serialization
33
import org.scalatest.funsuite.AnyFunSuite
44

55
final class NotUsedTransientDefault extends AnyFunSuite {
6+
case class Valid(@transientDefault a: String = "default")
7+
case class Invalid(@transientDefault a: String)
68

79
test("no warnings when @transientDefault is used properly") {
810
assertCompiles(
911
//language=Scala
1012
s"""
11-
|case class X(@transientDefault a: String = "default")
12-
|val codec = GenCodec.materialize[X]
13+
|GenCodec.materialize[Valid]
1314
|""".stripMargin
1415
)
1516
}
@@ -18,8 +19,7 @@ final class NotUsedTransientDefault extends AnyFunSuite {
1819
assertDoesNotCompile(
1920
//language=Scala
2021
s"""
21-
|case class X(@transientDefault a: String)
22-
|val codec = GenCodec.materialize[X]
22+
|GenCodec.materialize[Invalid]
2323
|""".stripMargin
2424
)
2525
}

macros/src/main/scala/com/avsystem/commons/macros/serialization/GenCodecMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class GenCodecMacros(ctx: blackbox.Context) extends CodecMacroCommons(ctx) with
134134
def isTransientDefault(param: ApplyParam, warnIfDefaultNotProvided: Boolean = false): Boolean =
135135
(hasAnnotation(param.sym, TransientDefaultAnnotType), param.defaultValue.nonEmpty, warnIfDefaultNotProvided) match {
136136
case (true, false, true) =>
137-
warning(s"@transientDefault has no effect on parameter ${param.sym.name} because it has no default value")
137+
error(s"@transientDefault has no effect on parameter ${param.sym.name} because it has no default value")
138138
false
139139
case (hasAnnotation, noDefaultValue, _) => hasAnnotation && noDefaultValue
140140
}

0 commit comments

Comments
 (0)