Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
62 views

So I have an annotation that looks like this: class FakeAnnotation(val strings: String*) extends StaticAnnotation val someVar = "Test" @FakeAnnotation(someVar) class TestClass I can't see ...
Tanin's user avatar
  • 1,973
1 vote
0 answers
121 views

I have an entity that generates Scala functions compiled dynamically using Scala 2's runtime reflection. My case is slightly more convoluted, but the following showcases the issue: import scala....
jcazevedo's user avatar
  • 217
1 vote
1 answer
121 views

I am creating a library and am exposing a class called A that has in it defined a function func(f: SomeType => A). It is imperative that func is called with the following syntax: val x = new A() ...
B-Brennan's user avatar
  • 133
0 votes
0 answers
77 views

Let's assume I have the code: trait Session { val value: Option[String] = None } case class A(v: Int) extends Session case class B(v: Int, s: String) extends Session def injectSession[T <: ...
Oren's user avatar
  • 1
1 vote
1 answer
416 views

The context is to register a UserDefinedFunction(UDF) in spark, where the UDF is an anonymous function obtained via reflection. Since the function signature of the function is determined at runtime, I ...
Hang Wu's user avatar
  • 15
0 votes
1 answer
280 views

My code compiled with Spark 3.1.2: private def work(plan: LogicalPlan): LogicalPlan = { val result = plan.transformDown { // irrelevant details } } When run with Spark 3.3.0, I run into: java....
stackoverflowflowflwofjlw's user avatar
1 vote
0 answers
244 views

package spark.course.example import org.apache.spark.sql.SparkSession import org.apache.spark.sql.functions.typedLit object Example extends App{ val spark: SparkSession = SparkSession.builder....
orsh's user avatar
  • 11
0 votes
2 answers
176 views

Given 2 Scala case classes case class Bar(x: Int) case class Foo(b: Bar, z: Double) I have a piece of code that prints the types of Foo fields using reflection: import scala.reflect.runtime.universe....
outlaw's user avatar
  • 241
0 votes
1 answer
203 views

Given the following object object functions { type MyOutput = String def f1: MyOutput = "res1" def f2: MyOutput = "res2" def f3(foo: String): Boolean = foo.equals("...
Hektor J.G.'s user avatar
0 votes
2 answers
160 views

I have been able to get a List of attributes for a case class using scala with Reflection. import scala.reflect.runtime.universe._ def classAccessors[T: TypeTag]: List[MethodSymbol] = typeOf[T]....
Ged's user avatar
  • 18.5k
0 votes
1 answer
262 views

I have a Scala reflection Symbol. val symbol = scala.reflect.api.Symbol how can I cast an object val obj: Any to the type of that Symbol ? reason why I am asking is that I have a implicit method to ...
linehrr's user avatar
  • 1,768
0 votes
1 answer
348 views

I am trying to generate a case class from a given case class that strips of Option from the fields. It needs to this recursively, so if the field itself is a case class then it must remove Option from ...
Aiono's user avatar
  • 403
0 votes
1 answer
264 views

The following code example shows the core of my question: // This is the base trait that the classes are extending trait Operation[T] { def operate(x: T): T } // Here are 2 case classes that exist ...
Koedlt's user avatar
  • 6,111
0 votes
0 answers
147 views

I have a Scala annotation with parameters, some with default values: case class A(x: String, y: Option[String] = None, z: Option[Boolean] = None) extends scala.annotation.StaticAnnotation The ...
Alex Savitsky's user avatar
0 votes
1 answer
135 views

I'm trying to write a generalised function that takes a Type of SomeSealedClass and uses reflection to return a list of values overridden by the trait's child classes/objects. sealed abstract class ...
Turbo123's user avatar
4 votes
1 answer
582 views

From the context of a Scala 3 Macro: def aMacroImpl[T](using Type[T], Quotes): Expr[SpecialMap[_, _, _]] = { import quotes.reflect._ val TRepr: TypeRepr = TypeRepr.of[T] val TSym: Symbol ...
Ben McKenneby's user avatar
0 votes
1 answer
362 views

I defined the case class dynamically using Toolbox. And when I do extract of json4s, I get the following exception: import org.json4s._ import scala.reflect.runtime._ import scala.tools.reflect....
Bum Su Kim's user avatar
-1 votes
1 answer
137 views

Let's say I have the following: val int_string = "Int" I want to get a map. In the process of running the program, I need to infer its type from the data, and then create a map,like in spark ...
season's user avatar
  • 41
1 vote
1 answer
377 views

I have found that scala compiler report compile error differently depends on whether it is used in compile-time or run-time. E.g. for a simple implicit not found case, in compile time the report is: ...
tribbloid's user avatar
  • 3,792
1 vote
1 answer
695 views

I am trying to create a UI to test a scala interface. To do so, I am extracting all the declared methods from the interface using java reflection. I am able to get the method names via Class[MyClass]....
Kyuubi's user avatar
  • 1,240
0 votes
0 answers
97 views

I need to implement Ad-hoc polymorphism, consider this code: trait BlockInputRequest case class StaticBlockInput( content: String ) extends BlockInputRequest case class StaticBlockOutput(...
Alex Z's user avatar
  • 1
2 votes
0 answers
71 views

I have a function which constructs a map by reflection from an object literal (the purpose is to make porting some JavaScript code easier). The function works fine, but I have found a case in which ...
Suma's user avatar
  • 34.6k
1 vote
0 answers
191 views

I'd like to convert a Map[String, Any] to a given case class, and the map can be a nested map. The case class can have certain fields as Optional, and if the map doesn't have the field in question , ...
ni_i_ru_sama's user avatar
0 votes
0 answers
134 views

This capability seems to be dropped by SI-6186, and no mechanism could be used to replace it I found the following remarks in its commit message: Now we restore the broken balance by banning TypeTag ...
tribbloid's user avatar
  • 3,792
1 vote
1 answer
216 views

This is a follow-up question of: How to get the name of a case class field as a string/symbol at compile time using shapeless? Assuming that I want to write a recursive converter that can convert a ...
tribbloid's user avatar
  • 3,792

1
2 3 4 5 6