Comments (7)
You'll see the same phenomenon with vanilla tagged types, eg.,
scala> import shapeless._
import shapeless._
scala> trait Foo
defined trait Foo
scala> tag[Foo](1)
res0: shapeless.tag.@@[Int,Foo] = 1
scala> tag[Foo](1: Any)
java.lang.ClassCastException: java.lang.Integer cannot be cast to shapeless.tag$Tagged
at .<init>(<console>:12)
...
Is this a showstopper for you, or are you able to make progress by avoiding ascribing Any
or AnyRef
?
from shapeless.
In sqltyped the following query no longer works:
sql("select name, ? as x from person")
Currently it is typed as (Stuff within curlies are records, not structural types. I'm using that syntax just for readability here):
Any => List[{ name: String, x: Any }]
Any, because we do not know anything about x. That's not a deal breaker though. I can drop support for those queries. It is not very common to just send data to database server only to return it back. Perhaps more common is to execute some function in a database like:
sql("select name, upper(?) as x from person")
Typing at least some of SQL queries like that might succeed. Here we at least know that 'upper' returns VARCHAR.
In general, when using records this may cause some unexpected crashes when scalac infers too general type.
def bar(x: Int) = if (x > 10) 5 else "10"
... then in some other source file etc. ....
"foo" ->> bar(2)
java.lang.ClassCastException: java.lang.String cannot be cast to shapeless.record$KeyTag
Now it is not very easy to figure out the cause of the problem. But I guess this is pretty hard to fix, right?
from shapeless.
I'm afraid so. If you can work around it for now I'll see what I can do for M2.
from shapeless.
Yes, no problem. Thanks!
from shapeless.
Still present in shapeless 2.0.0 and with Scala 2.11.1 ... is this still an issue for you?
from shapeless.
It is still an issue but not a critical one. It is a rather rare corner case.
from shapeless.
Still present in shapeless 2.3.0-SNAPSHOT and with Scala 2.11.7. A fix would most likely involved reverting #20 and that currently breaks records. I'll punt this to 3.0.0.
from shapeless.
Related Issues (20)
- implicit summoning of records.Keys for singleton subtype of HList fail sporadically HOT 3
- Witness path-dependent type `T` lose refinement HOT 3
- Witness singleton type automatically erased by compile-time type inference HOT 3
- migrate to GitHub Actions HOT 1
- Implicit is not returned from the cache but rather from current scope HOT 3
- Tagged types based on anything other than AnyVals produces exception in Spark HOT 12
- Migrate to GitHub actions HOT 1
- `Default.AsRecord` causes `StackOverflow` in a path-dependent type's companion object HOT 5
- `ops.coproduct.Reify` broken HOT 1
- performance issue with combined `Length` and `ToSizedHList` implicit derivation HOT 3
- Generic in shapeless 2.3.5+ not working for classes with context bounds if some implicit value is present HOT 2
- Generic.Aux compiles but errors with ClassCastException at runtime HOT 3
- Shapeless 2.3.5+ can't provide implicit for Generic.Aux HOT 5
- _0 as defined is somehow causing extreme compile times HOT 1
- Possible derivation regression since shapeless 2.3.8 HOT 3
- Strange behavior when using -release 8 scalac option HOT 3
- Fix annotations with type parameter
- Shouldn't `KeyTag` be an abstract type rather than a trait? HOT 4
- `Generic` is not materialized in macro-generated companion object of nested case class HOT 1
- MkFieldLens.mkFieldLens returns a derived type instead of type parameter
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 shapeless.