Skip to content

Commit 7eab684

Browse files
committed
Accommodate Scala 2 annotation value
1 parent 83d4962 commit 7eab684

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object Annotations {
3838
if (i < args.length) Some(args(i)) else None
3939
}
4040
def argumentConstant(i: Int)(using Context): Option[Constant] =
41-
for (case ConstantType(c) <- argument(i) map (_.tpe.widenTermRefExpr.normalized)) yield c
41+
for case ConstantType(c) <- argument(i).map(stripCast(_).tpe.widenTermRefExpr.normalized) yield c
4242

4343
def argumentConstantString(i: Int)(using Context): Option[String] =
4444
for (case Constant(s: String) <- argumentConstant(i)) yield s

tests/neg/serialversionuid-not-const.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@SerialVersionUID(13l.toLong) class C1 extends Serializable // OK because toLong is constant-folded
22
@SerialVersionUID(13l) class C2 extends Serializable // OK
3-
@SerialVersionUID(13.asInstanceOf[Long]) class C3 extends Serializable // error
3+
@SerialVersionUID(13.asInstanceOf[Long]) class C3 extends Serializable // OK was error
44
@SerialVersionUID(Test.bippy) class C4 extends Serializable // error
55

66
object Test {

0 commit comments

Comments
 (0)