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

make object Disabled extend Disabled #290

Merged
merged 1 commit into from
Jan 24, 2019

Conversation

eed3si9n
Copy link
Member

@eed3si9n eed3si9n commented Jan 22, 2019

Ref #280
Ref sbt/contraband#127

This is to workaround bincompat error detected by sbt community build.

[cats] [error] java.lang.NoSuchMethodError: sbt.librarymanagement.CrossVersion$.Disabled()Lsbt/librarymanagement/Disabled$;

@dwijnand
Copy link
Member

LGTM if it works.

@typesafe-tools
Copy link

A validation involving this pull request is in progress...

@typesafe-tools
Copy link

The validator has checked the following projects, tested using dbuild, projects built on top of each other.

Project Reference Commit
sbt develop sbt/sbt@88624cb
zinc develop sbt/zinc@5ff3ba8
io develop sbt/io@dda3762
librarymanagement pull/290/head 80c3975
util develop sbt/util@2e0d2d9

✅ The result is: SUCCESS
(restart)

@eed3si9n
Copy link
Member Author

I am still getting

[error] java.lang.NoSuchMethodError: sbt.librarymanagement.CrossVersion$.Disabled()Lsbt/librarymanagement/Disabled$;
[error] 	at scala.scalanative.sbtplugin.SBTCompat$.crossVersionAddPlatformPart(SBTCompat.scala:13)
[error] 	at scala.scalanative.sbtplugin.ScalaNativeCrossVersion$.scalaNativeMapped(ScalaNativeCrossVersion.scala:22)
[error] 	at scala.scalanative.sbtplugin.ScalaNativeCrossVersion$.<init>(ScalaNativeCrossVersion.scala:24)
[error] 	at scala.scalanative.sbtplugin.ScalaNativeCrossVersion$.<clinit>(ScalaNativeCrossVersion.scala)
[error] 	at scala.scalanative.sbtplugin.ScalaNativePlugin$autoImport$.<init>(ScalaNativePlugin.scala:13)
[error] 	at scala.scalanative.sbtplugin.ScalaNativePlugin$autoImport$.<clinit>(ScalaNativePlugin.scala)
[error] 	at scala.scalanative.sbtplugin.ScalaNativePlugin$.<init>(ScalaNativePlugin.scala:45)
[error] 	at scala.scalanative.sbtplugin.ScalaNativePlugin$.<clinit>(ScalaNativePlugin.scala)

Now I think the problem is return type. We should've changed the companion object Disabled to extend Disabled class.

Ref sbt#280

This is to workaround bincompat error detected by sbt community build.

```
[cats] [error] java.lang.NoSuchMethodError: sbt.librarymanagement.CrossVersion$.Disabled()Lsbt/librarymanagement/Disabled$;
```
@eed3si9n eed3si9n force-pushed the wip/disabled-bincompat branch from 80c3975 to 75c319e Compare January 23, 2019 20:07
@eed3si9n eed3si9n changed the title change final val Disabled to def make object Disabled extend Disabled Jan 23, 2019
@typesafe-tools
Copy link

A validation involving this pull request is in progress...

@typesafe-tools
Copy link

The validator has checked the following projects, tested using dbuild, projects built on top of each other.

Project Reference Commit
sbt develop sbt/sbt@88624cb
zinc develop sbt/zinc@5ff3ba8
io develop sbt/io@dda3762
librarymanagement pull/290/head 75c319e
util develop sbt/util@2e0d2d9

✅ The result is: SUCCESS
(restart)

@eed3si9n
Copy link
Member Author

Confirmed that Cats build works.

@eed3si9n eed3si9n merged commit 82735ae into sbt:develop Jan 24, 2019
@eed3si9n eed3si9n deleted the wip/disabled-bincompat branch January 24, 2019 00:40
@eed3si9n
Copy link
Member Author

eed3si9n commented Apr 1, 2019

I think this is breaking JSON deserialization in sbt 1.3 nightly.

[error] scala.MatchError: Disabled() (of class sbt.librarymanagement.Disabled$)
[error] 	at sjsonnew.FlatUnionFormats$$anon$5.write(FlatUnionFormats.scala:220)
[error] 	at sjsonnew.JsonWriter.addField(JsonFormat.scala:40)
[error] 	at sjsonnew.JsonWriter.addField$(JsonFormat.scala:37)
[error] 	at sjsonnew.FlatUnionFormats$$anon$5.addField(FlatUnionFormats.scala:208)

eed3si9n added a commit to eed3si9n/librarymanagement that referenced this pull request Apr 2, 2019
Fixes sbt/sbt#4595
Ref sbt#290
Ref sbt#280

This is bit of an odd one.

To keep bincompat and also to fix sbt 0.13 compatibility issue we have made `Disabled` companion object extend `Disabled` type.
This actually created a subtle deserialization issue:

```
[error] scala.MatchError: Disabled() (of class sbt.librarymanagement.Disabled$)
[error] 	at sjsonnew.FlatUnionFormats$$anon$5.write(FlatUnionFormats.scala:220)
[error] 	at sjsonnew.JsonWriter.addField(JsonFormat.scala:40)
[error] 	at sjsonnew.JsonWriter.addField$(JsonFormat.scala:37)
[error] 	at sjsonnew.FlatUnionFormats$$anon$5.addField(FlatUnionFormats.scala:208)
[error] 	at sjsonnew.Builder.addField(Builder.scala:43)
[error] 	at sbt.librarymanagement.ModuleIDFormats$$anon$1.write(ModuleIDFormats.scala:46)
```

This is because Contraband generates `flatUnionFormat5[CrossVersion, Disabled, ...]` for all of the subtypes of `CrossVersion`, which uses the runtime type information. Now that `Disabled` object is also in the mix, this created JSON that `CrossVersionFormats` cannot deserialize. This brings the code into src/ so we can write this part manually.
eed3si9n added a commit to eed3si9n/librarymanagement that referenced this pull request Aug 22, 2019
Fixes sbt/sbt#4975

This makes `CrossVersion.Disabled` a stable identifier by reverting `final def` back to `final val`.

This is to fix Scala.JS build

```
[error] ScalaJSCrossVersion.scala:34:23: stable identifier required, but sbt.`package`.CrossVersion.Disabled found.
[error]     case CrossVersion.Disabled =>
[error]                       ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
```

### notes

- sbt#121 added `final val Disabled = sbt.librarymanagement.Disabled` but it was just a companion object
- sbt#280 actually made it `final val Disabled = sbt.librarymanagement.Disabled()`, but this broke Cat's build that was calling `CrossVersion.Disabled()`
- sbt#290 changed to `final def Disabled = sbt.librarymanagement.Disabled` and `object Disabled extends sbt.librarymanagement.Disabled`
- This changes back to `final val Disabled = sbt.librarymanagement.Disabled` (but because we changed the companion object in sbt#290 that's ok)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants