Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9482: simplified Manifest synthesis #13142

Merged
merged 3 commits into from
Jul 25, 2021

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Jul 24, 2021

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 the equals method of Manifest, however optManifest[List[Int]] == optManifest[List[? <: Int]] because equality of ClassTypeManifest only cares about the runtimeClass, not type arguments

However 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

@bishabosha bishabosha requested a review from smarter July 24, 2021 11:18
Comment on lines +378 to +380
private def escapeJavaArray(elemTp: Type)(using Context): Type = elemTp match
case JavaArrayType(elemTp1) => defn.ArrayOf(escapeJavaArray(elemTp1))
case _ => elemTp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this method could be used to solve #13131 :)

@smarter smarter merged commit 7b4091b into scala:master Jul 25, 2021
@smarter smarter deleted the fix-9482-alt branch July 25, 2021 18:23
@bishabosha bishabosha added the release-notes Should be mentioned in the release notes label Aug 31, 2021
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OptManifest not resolved
3 participants