by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 09:52
    y6x2digc commented #10502
  • 08:28
    ex0ns commented #12070
  • Jul 09 18:19
    SethTisue commented #9108
  • Jul 09 15:34
    som-snytt commented #9108
  • Jul 09 15:27
    som-snytt commented #9106
  • Jul 09 15:11
    lrytz synchronize #9108
  • Jul 09 15:08
    scala-jenkins milestoned #9108
  • Jul 09 15:08
    lrytz opened #9108
  • Jul 09 14:09

    lrytz on pr8865

    min (compare)

  • Jul 09 14:02

    lrytz on 2.13.x

    Improve assertThrows, use it in… Fix checkHasElement to follow a… Merge pull request #9106 from s… (compare)

  • Jul 09 14:02
    lrytz closed #9106
  • Jul 09 13:34
    SethTisue demilestoned #9103
  • Jul 09 11:49
    SethTisue synchronize #1172
  • Jul 09 07:39
    lrytz synchronize #9106
  • Jul 09 06:46
    NthPortal labeled #9107
  • Jul 09 06:46
    NthPortal labeled #9107
  • Jul 09 05:44

    lrytz on pr8865

    (compare)

  • Jul 09 01:35
    szeiger commented #9107
  • Jul 09 01:34

    szeiger on indexed-sliding

    (compare)

  • Jul 09 01:34
    szeiger closed #9103
Will Sargent
@wsargent
I'm running a debugger and I swear it's just skipping lines
som-snytt
@som-snytt
@wsargent the problem is that it doesn't futz with it. scala/scala-dev#3
Will Sargent
@wsargent
@som-snytt ah-ha!
Kris Kalavantavanich
@kkalavantavanich
Hi contributors, what do you think about adding a simpleName method to Type? It's one of the things I realized Scala was missing compared to Java. In Java, there is a simpleName method that gets the short name (see https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getSimpleName--). Basically, I was thinking of a method that will return a simple name (= short name) for a type. For example, typeOf[Map[String, Int]].simpleName == "Map[String, Int]". In Scala, we don't have this, and the current workaround is quite lengthy (see https://stackoverflow.com/questions/60721147/how-to-get-generic-simple-class-name-from-scala-typetag). What do you think?
sinanspd
@sinanspd
are you referring to the Types trait in the reflection library?
Kris Kalavantavanich
@kkalavantavanich
Yes. Specifically, theTypeApi or Type, if I'm correct.
sinanspd
@sinanspd

ok. I wanted to set the context properly. I am not a person that is specifically interested in runtime reflection or one that uses it for that matter but here are my two cents about this:

To me, the goals of java.lang.Class.getSimpleName and extracting such information from TypeTags are different, so are the use cases. I think we should set your goals straight because the two links that you shared are contradicting.

typeOf[Map[String, Int]].simpleName == Map[String, Int]

Java's getSimpleName can not do this because of type erasure. It will only return you Map/ HashMap or whatever concrete implementation you are using. The type parameters will be lost.

If your goal is to simply imitate getSimpleName() than I don't think it is necessary because you can already do things like:


case class Q(name: String)
class Hello{}

val a = Q("hello").getClass.getName //Q
val b = new Hello().getClass.getName // Hello

Or use productPrefix among other techniques available.

On the other hand, the SO question you have linked specifically asks for extracting this information from the TypeTag (although it doesn't state a reason why, likely to preserve the type params perhaps? )

In that case, I would argue that typeOf[T].toString is not really a lengthy workaround but I haven't used the reflection library at all, let alone enough to know how common of a use case this is, so I will pass the ball to someone who is knowledgeable in the reflection library

Kris Kalavantavanich
@kkalavantavanich
OK :+1:
Nth/April
@NthPortal
is there a good tool for examining bytecode and describing what an indy does?
Will Sargent
@will_sargent_twitter
jitwatch I think
Will Sargent
@wsargent
just ran into scala/bug#11927
but happens in 2.12.11 so I don't think there's a fix out yet
Andriy Plokhotnyuk
@plokhotnyuk
Can be using of JDK 8 a workaround for that?
som-snytt
@som-snytt
@wsargent the commit says it is in 2.13.3 (merged forward) but 2.12.12 isn't released yet. https://github.com/scala/scala/pull/8849/commits/7580a83407ea131c1dff1b76a0da9a25f87b0421 Clicking thru "PRs merged for a release" doesn't give visibility into forward merges. https://github.com/scala/scala/pulls?q=is%3Amerged+milestone%3A2.13.3+author%3Alrytz
Will Sargent
@wsargent
som-snytt
@som-snytt
A logger by forax should be called lorax with the tag line, "I speak for the logs!"
Will Sargent
@will_sargent_twitter
forax does a bunch of neat stuff
Seth Tisue
@SethTisue

but happens in 2.12.11 so I don't think there's a fix out yet

@wsargent you might try the 2.12.12 release candidate: https://contributors.scala-lang.org/t/coming-soon-scala-2-12-12/4371/5

Will Sargent
@wsargent
ok
Will Sargent
@wsargent
Nth/April
@NthPortal
thanks @wsargent
som-snytt
@som-snytt
Favorite feature interaction of the day:
scala/build.sbt:399: warning: possible missing interpolator: detected interpolated identifier `$Keys`
    ProblemFilters.exclude[MissingClassProblem]("scala.collection.MapView$Keys"),
Will Sargent
@wsargent
@tisue the real PITA is scala/bug#7707 because it causes a spurious warning that interferes with fatal-warning flag
Seth Tisue
@SethTisue
@wsargent ah, shame — maybe use ghik/silencer (since there is no 2.12 backport of -Wconf) to silence it
Will Sargent
@wsargent
will do
this is a hairball
running scalafix causes scalafix java.util.concurrent.RejectedExecutionException
Dale Wijnand
@dwijnand
Is there a reason why there's no .upcast[Foo] or .widen[Foo] on Set, for intentional widenings?
I have a Set[Dog] and it's great that .contains("foo") is a type error, but now I need to pass it as a Set[Animal], mapping and casting aren't wonderful.
Guillaume Martres
@smarter
.toSet ?
Or to(Set[...]) maybe, not sure of the 2.13 syntax
Dale Wijnand
@dwijnand
toSet rebuilds just like map does
Guillaume Martres
@smarter
Is that actually sound?
Dale Wijnand
@dwijnand
For immutable sets, yes.
Guillaume Martres
@smarter
ah, I missed the import immutable.HashSet :)
moritz bust
@busti
Is the contributors board the right place to make suggestions for naming conventions in the stdlib?
Guillaume Martres
@smarter
Sure, but note that the stdlib is frozen for the foreseeable future
moritz bust
@busti
Good to know. Is it still possible to propose changes that take effect in the public release of dotty, or will dotty essentially ship with the 2.13 stdlib?
sinanspd
@sinanspd
Since 2.13 is the bridge to Scala 3.0 and the binary compatibility has to be maintained, the earliest such changes would be merged is Scala 3.1
or later
moritz bust
@busti
Makes sense, thanks a lot.
Mario Galic
@mario-galic

Does SLS 3.3.1 Method Types perhaps require updating the following statement

A special case are types of methods without any parameters. They are written here => T

because in 2.13.1

scala> def f[T] = ???
f: [T]=> Nothing

whilst in 2.13.2

scala> def f[T] = ???
def f[T]: Nothing

change introduced by https://github.com/scala/scala/pull/7798/commits/44955a6cfe59b4b1a06c5210cb4d7330f429ea0d#diff-ecaa4198a04261cd0e00a708b695eafbR2950

Also see https://stackoverflow.com/questions/62756187/scala-weird-type-when-coercing-parameterize-method-into-a-function/62757552

Guillaume Martres
@smarter
the statement is about how these types are referred to in the spec itself, what's there to update?
Will Sargent
@will_sargent_twitter