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

Stick TASTy reading behind a -Ytasty-reader flag #9293

Merged
merged 1 commit into from Nov 2, 2020

Conversation

dwijnand
Copy link
Member

@scala-jenkins scala-jenkins added this to the 2.13.5 milestone Oct 29, 2020
@dwijnand dwijnand modified the milestones: 2.13.5, 2.13.4 Oct 29, 2020
@dwijnand dwijnand mentioned this pull request Oct 29, 2020
72 tasks
Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

looks good with the warning

@SethTisue SethTisue added prio:blocker release blocker (used only by core team, only near release time) release-notes worth highlighting in next release notes labels Oct 29, 2020
@dwijnand dwijnand merged commit 7ef5a60 into scala:2.13.x Nov 2, 2020
@dwijnand dwijnand deleted the tasty-reading-behind-a-flag branch November 2, 2020 12:32
@dwijnand dwijnand removed the release-notes worth highlighting in next release notes label Nov 17, 2020
@@ -1114,6 +1116,8 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) {
case tpnme.ScalaATTR =>
isScalaRaw = true
i = numAttrs
case tpnme.TASTYATTR if !YtastyReader =>
MissingRequirementError.signal(s"Add -Ytasty-reader to scalac options to parse the TASTy in $file")

Choose a reason for hiding this comment

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

@dwijnand Why is it an error to unpickle a class file that has TASTY while running without -Ytasty-reader? How about silently skipping the attribute in this case?

Copy link
Member

Choose a reason for hiding this comment

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

IIRC, the idea was to fail eagerly when people unknowingly end up with Scala 3 classfiles on their classpath.

Skipping the attribute would mean the compiler treats Scala 3 classfiles like Java classfiles, I cannot imagine this would lead to a usable behavior?

Choose a reason for hiding this comment

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

Ah, thanks! So, there cannot be a scenario where there's regular Scala 2 metadata and TASTY?

Copy link

Choose a reason for hiding this comment

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

Also, how about the case where a Scala 3 classfile is on the class path but not referenced directly? It could be forced because you're referencing a Scala 2 symbol directly, which then depends on a symbol from a Scala 3 jar. In that case, you should be able to safely consume the Scala 2 classes without adding -Ytasty-reader, I think. (We're running into this error in the wild, but I have not yet figured out how exactly.)

Copy link
Member

Choose a reason for hiding this comment

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

there cannot be a scenario where there's regular Scala 2 metadata and TASTY?

That's right, Scala 3 doesn't emit ScalaSignatures (Scala 2 pickles), Scala 2 doesn't emit TSATy.

Scala 2 symbol which depends on a symbol from a Scala 3 jar

That's a good point. I haven't tested it, but it seems anything that depends on a Scala 3 jar "pollutes" the entire classpath.

Generally, publishing a Scala 2.13 library that depends on a Scala 3 library is discouraged, see https://docs.scala-lang.org/scala3/guides/migration/compatibility-classpath.html#disclaimer-for-library-maintainers. But in controlled environments this could be OK.

Choose a reason for hiding this comment

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

(The dependency in our case was pulled in by ammonite -- see cs resolve -t com.lihaoyi:ammonite-compiler-interface_2.13.6:2.4.0.)

Copy link
Member

Choose a reason for hiding this comment

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

cc @lihaoyi

└─ com.lihaoyi:ammonite-compiler-interface_2.13.6:2.4.0
   └─ com.lihaoyi:ammonite-cross-23-util_2.13:2.4.0
      ├─ com.lihaoyi:ammonite-cross-23-ops_2.13:2.4.0
      │  ├─ com.lihaoyi:os-lib_2.13:0.7.2
      │  │  └─ com.lihaoyi:geny_2.13:0.6.5
      │  └─ org.scala-lang.modules:scala-collection-compat_2.13:2.4.1
      │     └─ org.scala-lang:scala-library:2.13.4 -> 2.13.5
      ├─ com.lihaoyi:fansi_3:0.2.14
      │  └─ com.lihaoyi:sourcecode_3:0.2.7
      ├─ com.lihaoyi:pprint_3:0.6.6
      │  ├─ com.lihaoyi:fansi_3:0.2.14
      │  │  └─ com.lihaoyi:sourcecode_3:0.2.7
      │  └─ com.lihaoyi:sourcecode_3:0.2.7
      └─ org.scala-lang:scala3-library_3:3.0.0
         └─ org.scala-lang:scala-library:2.13.5

Copy link
Contributor

Choose a reason for hiding this comment

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

@alexarchambault is probably the expert here. I think we recently resolved an issue around accidental Scala3 dependencies in Ammonite? com-lihaoyi/Ammonite#1215

Choose a reason for hiding this comment

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

Thanks, looks like that should fix it! Would be great to get a release out with this fix. I've seen several places mention this crash while I was trying to figure out what was going on. (Sounds like the canonical issue is com-lihaoyi/Ammonite#1214)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we probably should. @alexarchambault would you be able to tag a 2.4.1 release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio:blocker release blocker (used only by core team, only near release time)
Projects
None yet
7 participants