Skip to content

Commit

Permalink
deprecate synthesis of Manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Jul 24, 2021
1 parent 5b98f8a commit 2a7a7ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,15 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):

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

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

0 comments on commit 2a7a7ec

Please sign in to comment.