File tree 3 files changed +18
-0
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1420,6 +1420,10 @@ trait Checking {
1420
1420
case Literal (_) => // ok
1421
1421
case _ =>
1422
1422
report.error(em " @ ${cls.name} needs a string literal as argument " , arg.srcPos)
1423
+ case Apply (tycon, arg :: Nil ) if cls == defn.ImplicitNotFoundAnnot || cls == defn.ImplicitAmbiguousAnnot =>
1424
+ arg.tpe.widenTermRefExpr.normalized match
1425
+ case _ : ConstantType => ()
1426
+ case _ => report.error(em " @ ${cls.name} requires constant expressions as a parameter " , arg.srcPos)
1423
1427
case _ =>
1424
1428
tree
1425
1429
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg/i22367.scala:3:36 ----------------------------------------------------------------------------------
2
+ 3 |@annotation.implicitAmbiguous("cba".reverse) // error
3
+ | ^^^^^^^^^^^^^
4
+ | @implicitAmbiguous requires constant expressions as a parameter
5
+ -- Error: tests/neg/i22367.scala:6:47 ----------------------------------------------------------------------------------
6
+ 6 |def f(using @annotation.implicitNotFound("cba".reverse) e: E[Int]): Unit = () // error
7
+ | ^^^^^^^^^^^^^
8
+ | @implicitNotFound requires constant expressions as a parameter
Original file line number Diff line number Diff line change
1
+ trait E [T ]
2
+
3
+ @ annotation.implicitAmbiguous(" cba" .reverse) // error
4
+ given E [Int ] = ???
5
+
6
+ def f (using @ annotation.implicitNotFound(" cba" .reverse) e : E [Int ]): Unit = () // error
You can’t perform that action at this time.
0 commit comments