Skip to content

Commit f1c1195

Browse files
committed
deprecate synthesis of Manifests
1 parent 798af02 commit f1c1195

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,15 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
472472

473473
formal.argInfos match
474474
case arg :: Nil =>
475-
synthesize(fullyDefinedType(arg, "Manifest argument", span), kind, topLevel = true)
475+
val manifest = synthesize(fullyDefinedType(arg, "Manifest argument", span), kind, topLevel = true)
476+
if manifest != EmptyTree then
477+
report.deprecationWarning(
478+
i"""Compiler synthesis of Manifest and OptManifest is deprecated,
479+
|and calls should be replaced by `reflect.classTag[$arg]`.
480+
|Alternatively, the using new metaprogramming features of Scala 3
481+
|could help avoid the need for runtime type information, see
482+
|https://docs.scala-lang.org/scala3/reference/metaprogramming.html""", ctx.source.atSpan(span))
483+
manifest
476484
case _ =>
477485
EmptyTree
478486

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Error: tests/neg-custom-args/deprecation/manifest-summoning.scala:1:34 ----------------------------------------------
2+
1 |val foo = manifest[List[? <: Int]] // error
3+
| ^
4+
| Compiler synthesis of Manifest and OptManifest is deprecated,
5+
| and calls should be replaced by `reflect.classTag[List[? <: Int]]`.
6+
| Alternatively, the using new metaprogramming features of Scala 3
7+
| could help avoid the need for runtime type information, see
8+
| https://docs.scala-lang.org/scala3/reference/metaprogramming.html
9+
-- Error: tests/neg-custom-args/deprecation/manifest-summoning.scala:2:41 ----------------------------------------------
10+
2 |val bar = optManifest[Array[? <: String]] // error
11+
| ^
12+
| Compiler synthesis of Manifest and OptManifest is deprecated,
13+
| and calls should be replaced by `reflect.classTag[Array[? <: String]]`.
14+
| Alternatively, the using new metaprogramming features of Scala 3
15+
| could help avoid the need for runtime type information, see
16+
| https://docs.scala-lang.org/scala3/reference/metaprogramming.html
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
val foo = manifest[List[? <: Int]] // error
2+
val bar = optManifest[Array[? <: String]] // error

0 commit comments

Comments
 (0)