Fix #9482: simplified Manifest synthesis #13142
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is an alternative to #13129, it approximates what Scala 2 does but with some simplification.
The goal of the implementation is to say that for the following expressions compiled by Scala 2 that yield true:
manifest[A] == manifest[B]
manifest[A].runtimeClass == manifest[B].runtimeClass
optManifest[A] == optManifest[B]
optManifest[A].asInstanceOf[ClassTag[A]].runtimeClass == optManifest[B].asInstanceOf[ClassTag[B]].runtimeClass
then the same snippets compiled by Scala 3 should also be true.
This means
manifest[List[Int]] != manifest[List[? <: Int]]
because type arguments are compared in theequals
method ofManifest
, howeveroptManifest[List[Int]] == optManifest[List[? <: Int]]
because equality ofClassTypeManifest
only cares about theruntimeClass
, not type argumentsHowever the implementation does not care about replicating the exact expressions compiled by Scala 2, so
toString
can differ.This PR also creates a deprecation warning whenever a Manifest is successfully synthesized.
fixes #9482