Comments (4)
this is a work around, but rather verbose:
@ScalaJSDefined
trait Mutations extends js.Object {
def increment(state: State)
def decrement(state: State)
}
val mutations = new Mutations {
def increment(state: State) = state.count+=1
def decrement(state: State) = state.count-=1
}
// works fine:
val name = nameOf(mutations.increment _)
from scala-nameof.
Am I correct that this is scalajs specific? It works with java.lang.Object
in place of js.Object
from scala-nameof.
yes, there are bunch of restrictions
https://www.scala-js.org/doc/interoperability/sjs-defined-js-classes.html
from scala-nameof.
From looking at https://www.scala-js.org/doc/interoperability/sjs-defined-js-classes.html#caveat-with-reflective-calls it seems this behavior is intended. I don't think there is anything we can do
from scala-nameof.
Related Issues (14)
- Compile time whitebox macro returns a type that is too wide
- Can I use nameOf[T](function) to get the field name HOT 1
- how can I use this in maven project HOT 1
- please make NameOfImpl public HOT 2
- object dwickern is not a member of package com.github HOT 2
- [Question] Can I use it for function or method parameter names?
- Scala 3 HOT 2
- Scala.js in v4.0.0 HOT 3
- [Problem] unable to get correct key name string in a for loop HOT 1
- current reflection api HOT 1
- doesn't work for Java compile-time constants
- Scala 2.13 support HOT 1
- how to use nameOf for overloaded methods HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-nameof.