-
-
Notifications
You must be signed in to change notification settings - Fork 286
Inlining code in Scala targets #1717
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
Comments
Scala issue: scala/bug#13097 |
Bazel will use ijars for dependencies in your Scala targets for:
Ijars won't be used for:
It happens to be the case that It seems that inlining code is very similar to using macros. If you want to inline code:
Before Scala 2.13.* is fixed, these steps are necessary to make your code compile (when using inlining), after 2.13.17, you need this to ensure Scala will be able to inline that code and won't emit warnings. |
Just for clarity, the inline instruction that my project uses is |
The Scala bugfix was merged, should be in Scala 2.13.17. This means that Scala compiler won't throw an exception starting from then, but inlining code from hjar/ijar dependencies will be simply ignored. |
Note that you can test it in a nightly if you like (https://docs.scala-lang.org/overviews/core/nightlies.html) The current nightly is 2.13.17-bin-f5faa03 |
Thanks @SethTisue, greatly appreciated! |
Thanks @SethTisue, I can confirm that with |
I haven't seen a warning though, as compiling this code. |
How one can use a "nightly" Scala version... Patch file for rules_scala itself. diff --git a/scala/scala_cross_version.bzl b/scala/scala_cross_version.bzl
index f7d8980..42188f2 100644
--- a/scala/scala_cross_version.bzl
+++ b/scala/scala_cross_version.bzl
@@ -21,6 +21,7 @@ def default_maven_server_urls():
"https://maven-central.storage-download.googleapis.com/maven2",
"https://mirror.bazel.build/repo1.maven.org/maven2",
"https://jcenter.bintray.com",
+ "https://scala-ci.typesafe.com/artifactory/scala-integration",
]
def extract_major_version(scala_version):
@@ -28,7 +29,7 @@ def extract_major_version(scala_version):
return scala_version[:scala_version.find(".", 2)]
def extract_minor_version(scala_version):
- return scala_version.split(".")[2]
+ return scala_version.split(".")[2].split("-")[0]
def extract_major_version_underscore(scala_version):
"""Return major Scala version with underscore given a full version,
diff --git a/scala/scala_cross_version_select.bzl b/scala/scala_cross_version_select.bzl
index 615b6a7..4695ff7 100644
--- a/scala/scala_cross_version_select.bzl
+++ b/scala/scala_cross_version_select.bzl
@@ -1,5 +1,5 @@
-load(":scala_cross_version.bzl", "version_suffix")
load("@rules_scala_config//:config.bzl", "SCALA_VERSIONS")
+load(":scala_cross_version.bzl", "version_suffix")
def select_for_scala_version(default = [], **kwargs):
"""
@@ -61,7 +61,7 @@ def _matches_for_version(scala_version, kwargs, default_value):
def _match_one_arg(scala_version, matcher_scala_version, compare):
# Some rudimentary version parsing to allow a lexicographical compare later.
# Works for versions containing numbers only.
- scala_version = tuple([int(x) for x in scala_version.split(".")])
+ scala_version = tuple([int(x.split("-")[0]) for x in scala_version.split(".")])
matcher_scala_version = tuple([int(x) for x in matcher_scala_version.split("_")])
# Compare only a part of version – to allow wildcarding.
diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl
index c0e7b0a..4952cdf 100644
--- a/third_party/repositories/scala_2_13.bzl
+++ b/third_party/repositories/scala_2_13.bzl
@@ -3,7 +3,7 @@
Mostly generated and updated by scripts/create_repository.py.
"""
-scala_version = "2.13.17"
+scala_version = "2.13.17-bin-f5faa03"
artifacts = {
"com_github_jnr_jffi_native": {
@@ -184,8 +184,8 @@ artifacts = {
],
},
"io_bazel_rules_scala_scala_compiler": {
- "artifact": "org.scala-lang:scala-compiler:2.13.16",
- "sha256": "f59982714591e321ba9c087af2c8666e2f5fb92b11a0cef72c2c5e9b342152d3",
+ "artifact": "org.scala-lang:scala-compiler:2.13.17-bin-f5faa03",
+ "sha256": "eae22a432cac9c329f2dd0212cd68f92c8579d87679c8ca1708aee3c57e2d572",
"deps": [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
@@ -194,8 +194,8 @@ artifacts = {
],
},
"io_bazel_rules_scala_scala_library": {
- "artifact": "org.scala-lang:scala-library:2.13.16",
- "sha256": "1ebb2b6f9e4eb4022497c19b1e1e825019c08514f962aaac197145f88ed730f1",
+ "artifact": "org.scala-lang:scala-library:2.13.17-bin-f5faa03",
+ "sha256": "d01f578049ccad2a39d12c412632ed6ae41987b6d043865aa57b4dc4fd2b8b4c",
},
"io_bazel_rules_scala_scala_parallel_collections": {
"artifact": "org.scala-lang.modules:scala-parallel-collections_2.13:1.2.0",
@@ -212,8 +212,8 @@ artifacts = {
],
},
"io_bazel_rules_scala_scala_reflect": {
- "artifact": "org.scala-lang:scala-reflect:2.13.16",
- "sha256": "fb49ccd9cac7464486ab993cda20a3c1569d8ef26f052e897577ad2a4970fb1d",
+ "artifact": "org.scala-lang:scala-reflect:2.13.17-bin-f5faa03",
+ "sha256": "9152c89795d6341040abacae69418d49237ba5d984998feb76e371703ba9997f",
"deps": [
"@io_bazel_rules_scala_scala_library",
],
@@ -439,8 +439,8 @@ artifacts = {
],
},
"org_scala_lang_scalap": {
- "artifact": "org.scala-lang:scalap:2.13.16",
- "sha256": "7963c72c4c74d52278e42b0108ae8ae866d4d1c4579e20209a2f9617e6aacfca",
+ "artifact": "org.scala-lang:scalap:2.13.17-bin-f5faa03",
+ "sha256": "cc322cbd07722d203fd39f8055d1b2ac82420079768457f3f7d98387f7492fcb",
"deps": [
"@io_bazel_rules_scala_scala_compiler",
], Apart from that, obviously, you also need to change your project to use this nightly version. |
Uh oh!
There was an error while loading. Please reload this page.
With Scala 2.13.16 if you try inlining code that has been added to your classpath as an ijar/hjar it throws an exception:
This seems to be a Scala regression since 2.13.9+ and Scala declares that it will fix it in 2.13.17.
Steps to reproduce:
Example code:
Using the following scalacopt:
-opt-inline-from:**
.Once Scala fixes this bug, it will stop inlining code from signature jar files, but you'll get a warning:
This behavior is caused by Bazel using hjars/ijars for dependencies.
Related Bazel Slack topics:
The text was updated successfully, but these errors were encountered: