scalac

Scala read method annotations from another project

旧城冷巷雨未停 提交于 2021-01-29 16:14:53
问题 I have a sbt config with scala play! server, a scalajs client, and shared project which contains classes which are passed between the two. I want my client to have strong type information for the server API calls so I'm writing a task that for each route in the routes file builds a corresponding method in the client. I have a prototype that is able to parse almost all of the information I need out of the routes file. The only thing I can't get is return types. Here's what I have so far (I

In scala, are there any condition where implicit view won't be able to propagate to other implicit function?

核能气质少年 提交于 2020-08-20 10:35:27
问题 Assuming that A class called 'summoner' was defined, that is capable of summoning implicit views from the scope: case class Summoner[R]() { def summon[T](v: T)(implicit ev: T => R): R = ev(v) } I found that it works most of the time, but there are cases where it doesn't work, e.g. the following is a (not too) short case which uses the singleton-ops library: import shapeless.Witness import singleton.ops.+ import singleton.ops.impl.Op trait Operand { def +[ X >: this.type <: Operand, Y <:

Could not find proxy for … in Macro

吃可爱长大的小学妹 提交于 2020-01-05 01:13:52
问题 I have been chasing the following issue for quite a while and am hoping someone with more experience on this than myself can help me resolve it. In my test-case the exact error is as follows: java.lang.IllegalArgumentException: Could not find proxy for val user: specs.BasicSpec#User in List(value user, method applyOrElse, , method $anonfun$new$97, value fiveLetterNames, method $anonfun$new$90, method $anonfun$new$20, value , class BasicSpec, package specs, package ) (currentOwner= value

How do I disambiguate in Scala between methods with vararg and without

a 夏天 提交于 2019-12-28 02:07:14
问题 I'm trying to use the java jcommander library from Scala. The java JCommander class has multiple constructors: public JCommander(Object object) public JCommander(Object object, ResourceBundle bundle, String... args) public JCommander(Object object, String... args) I want to to call the first constructor that takes no varargs. I tried: jCommander = new JCommander(cmdLineArgs) I get the error: error: ambiguous reference to overloaded definition, both constructor JCommander in class JCommander

Why does scalac need a transitive dependency on the classpath

耗尽温柔 提交于 2019-12-24 01:16:29
问题 I'm running into an unexpected (only for me?) ScalaC behavior. The TL;DR is that the following is a recreation of an issue I saw while trying to migrate a codebase from maven to bazel. One of the main focuses of this migration is to try to minimize the dependencies each class needs for compilation so that builds will be triggered only when needed. Unfortunately what I saw is that given ClassIndirectlyNeedingFoo (uses)-> ClassUsingFoo (uses)-> Supplier the compilation of

Why does scalac need to box an `Int` in a method expecting an `Any`

让人想犯罪 __ 提交于 2019-12-23 12:44:01
问题 Consider the following class: package test class Test { def main(args: Array[String]): Unit = { val i: Int = 0 println(i) } } The bytecode of main is: public main([Ljava/lang/String;)V // parameter final args L0 LINENUMBER 4 L0 ICONST_0 L1 ISTORE 2 L2 LINENUMBER 5 L2 GETSTATIC scala/Predef$.MODULE$ : Lscala/Predef$; ILOAD 2 INVOKESTATIC scala/runtime/BoxesRunTime.boxToInteger (I)Ljava/lang/Integer; INVOKEVIRTUAL scala/Predef$.println (Ljava/lang/Object;)V L3 RETURN L4 LOCALVARIABLE i I L1 L3

sbt 0.12.4 - there were x feature warning(s); re-run with -feature for details

只愿长相守 提交于 2019-12-21 04:09:05
问题 I get an error there were 15 feature warning(s); re-run with -feature for details : $ /usr/local/sbt/bin/sbt [info] Loading project definition from /home/alex/Documents/projects/my_app123/project [info] Set current project to sbt-android (in build file:/home/alex/Documents/projects/my_app123/) > compile -feature [error] Expected end of input. [error] compile -feature [error] ^ > sbt-version [info] 0.12.4 > compile [warn] Credentials file /home/alex/.ivy2/.credentials does not exist [info]

Why can't scalac optimize tail recursion in certain scenarios?

送分小仙女□ 提交于 2019-12-12 08:35:08
问题 Why doesn't scalac (the Scala compiler) optimize tail recursion? Code and compiler invocations that demonstrates this: > cat foo.scala class Foo { def ifak(n: Int, acc: Int):Int = { if (n == 1) acc else ifak(n-1, n*acc) } } > scalac foo.scala > jd-gui Foo.class import scala.ScalaObject; public class Foo implements ScalaObject { public int ifak(int n, int acc) { return ((n == 1) ? acc : ifak(n - 1, n * acc)); } } 回答1: Methods that can be overridden can NOT be tail recursive. Try this: class