Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 13:21
    som-snytt commented #7515
  • 13:21
    som-snytt edited #7515
  • 12:07
    myazinn commented #12440
  • 11:56
    som-snytt closed #12440
  • 11:56
    som-snytt commented #12440
  • 10:26
    myazinn edited #12440
  • 10:24
    myazinn opened #12440
  • 08:47

    nicolasstucki on main

    Clean up grammar and other nit … Clean up grammar and other nit … Clean up grammar and other nit … and 2 more (compare)

  • 08:47
    nicolasstucki closed #2121
  • 08:46
    nicolasstucki assigned #2148
  • 08:26
    sjrd commented #1265
  • 08:23
    lrytz edited #12439
  • 08:23
    lrytz milestoned #12439
  • 08:23
    lrytz opened #12439
  • 08:23
    lrytz labeled #12439
  • 08:23
    lrytz labeled #12439
  • 07:18
    lrytz commented #9672
  • 06:15
    retronym synchronize #9656
  • 06:12
    retronym commented #9656
  • 06:01
    retronym synchronize #9656
Will Sargent
@wsargent
okay that makes more sense
Will Sargent
@wsargent
is there an equivalent of untypecheck in Scala 3? Still working on https://github.com/lampepfl/dotty/discussions/13042
Guillaume Martres
@smarter
there isn't, the reflection API only deals with typed trees.
Will Sargent
@wsargent
also https://softwaremill.com/scala-3-macros-tips-and-tricks/ says that the way to create an Ident is using the Ref constructor
"Another construct which you'll frequently spot when printing out trees are Idents. But how to create one? Turns out, the answer is the Ref constructor, which takes a Symbol, and basing on whatever that symbol is representing, creates an appropriate implementation."
Will Sargent
@wsargent
so I think the problem here is that I don't have a reference at the point of a ValDef because there's no val
zygfryd
@zygfryd
@wsargent Won't oldValDef.symbol let you create a new one? As long as you're not changing the type at least
Will Sargent
@wsargent
@zygfryd thank you, that was what I needed.
now I just need to be able to get the modified def inlined
val modified = DefDef.copy(defdef)(name = name, paramss = paramss, d, Some(Block(result, expr)))
Inlined(call, bindings, modified).asExprOf[A]
how do I get the modified tree inlined
zygfryd
@zygfryd
You can probably betaReduce it, there are methods for that both for Expr and Tree if I remember correctly
Will Sargent
@wsargent
I'm trying things like
val modified = DefDef.copy(defdef)(name = name, paramss = paramss, d, Some(Block(result, expr)))
val blockList = Block(Nil, Block(List(modified), Closure(???, None)))
Inlined(call, bindings, blockList).asExprOf[A]
Will Sargent
@wsargent
              val modified = DefDef.copy(defdef)(name = name, paramss = paramss, d, Some(Block(result, expr)))
              val someRef = Ref(modified.symbol)
              Inlined(call, bindings, someRef).asExprOf[A]
works but I think I need a freshName / newName to make the ref work
Dmitrii Naumenko
@unkarjedy

What is the proper way to run separate tests in dotty project?
Running for example sbt testOnly xsbt.DependencySpecification does nothing.

In the output there are several lines like No tests to run for scala3-interfaces / Test / testOnly
But scala3-sbt-bridge-test is not even listed there.

Guillaume Martres
@smarter
testOnly is going to delegate to the default scala3 project, which doesn't aggregate all projects (just those that are part of the compiler)
1 reply
oh and there's something weird with the bridge where the tests are in a separate project from the bridge itself
ah lol and the tests were disabled a while ago and no one re-enabled them: https://github.com/lampepfl/dotty/blob/b61eb2e864fef856f380a27eabb11f4eb7a67c19/project/Build.scala#L993-L995
1 reply
Will Sargent
@wsargent
still making progress
I can now def a method with the new block
              val modified = DefDef(myMethodSymbol, {
                case List() => Some(Block(result, expr))
              })
              println(s"modified = $modified")
              val someRef = Ref(modified.symbol)
              println(s"modified ident = $someRef")
              Inlined(call, bindings, someRef)
but it says the method is being called outside its scope
"While expanding a macro, a reference to method newMethodName was used outside the scope where it was defined"
Will Sargent
@wsargent
now it's saying "Could not find proxy for val a: Int in List(val a, method block$proxy1, " so I think I need to change the owner for all the Statements to be the new method name?
12 replies
Override-6
@Override-6
could somebody explain me this ???
Exception in thread "main" java.util.NoSuchElementException: None.get
    at scala.None$.get(Option.scala:627)
    at scala.None$.get(Option.scala:626)
    at scala.Option.orNull(Option.scala:201)
    at fr.linkit.engine.connection.cache.NetworkSharedCacheManager.$anonfun$getCache0$2(NetworkSharedCacheManager.scala:157)
i got that too :
Override-6
@Override-6
OOhh i see my bad
it's because the None returned was deserialized
so it's not the same instance of the None companion
Fabio Pinheiro
@FabioPinheiro
@smarter I think I found another incremental compilation inconsistent
After moving extension method from one file to another in the same package (in main source)
I got the a NoClassDefFoundError error (where running 'test'):
[error] Test suite SHA256Test failed with java.lang.NoClassDefFoundError: io/iohk/atala/swetest/minichain$package$.
[error] This may be due to the ClassLoaderLayeringStrategy (ScalaLibrary) used by your task.
[error] To improve performance and reduce memory, sbt attempts to cache the class loaders used to load the project dependencies.
[error] The project class files are loaded in a separate class loader that is created for each test run.
[error] The test class loader accesses the project dependency classes using the cached project dependency classloader.
[error] With this approach, class loading may fail under the following conditions:
[error]
[error]  * Dependencies use reflection to access classes in your project's classpath.
[error]    Java serialization/deserialization may cause this.
[error]  * An open package is accessed across layers. If the project's classes access or extend
[error]    jvm package private classes defined in a project dependency, it may cause an IllegalAccessError
[error]    because the jvm enforces package private at the classloader level.
[error]
[error] These issues, along with others that were not enumerated above, may be resolved by changing the class loader layering strategy.
[error] The Flat and ScalaLibrary strategies bundle the full project classpath in the same class loader.
[error] To use one of these strategies, set the  ClassLoaderLayeringStrategy key
[error] in your configuration, for example:
[error]
[error] set root / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
[error] set root / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
[error]
[error] See ClassLoaderLayeringStrategy.scala for the full list of options.
[error] Failed: Total 10, Failed 1, Errors 0, Passed 9
[error] Failed tests:
[error]     SHA256Test
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 0 s, completed Jul 15, 2021 5:14:01 PM
Guillaume Martres
@smarter
great, please report
Fabio Pinheiro
@FabioPinheiro
Where do I get the name of the version for the scala's NIGHTLY build?
Before I was using dottyLatestNightlyBuild.get
Guillaume Martres
@smarter
you can find it in https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml but there's not automatic way to get it otherwise
Fabio Pinheiro
@FabioPinheiro
Thanks @smarter
Issue reported on lampepfl/dotty#13085
Override-6
@Override-6
How does scala stores a lambda in the class file ?
Seth Tisue
@SethTisue
@Override-6 have you taken a look with javap?
scala 2.13.6> class C { val fn = (x: Int) => x * x }
class C

scala 2.13.6> :javap C
...
there's a static method holding the method body, a BootstrapMethods entry, and then invokedynamic spins up the corresponding value
it's modeled after what Java does, so when you're researching, materials coving Java are likely to be relevant
Override-6
@Override-6
okay thanks, actually, i already knew it, but i had a weird bug when modifying the lambda declaration that me doubt about that... (and yes, i looked in javap but i'm quite dumb sometimes)
Fabio Pinheiro
@FabioPinheiro

Can you check if the documentation and the behavior are right about the method defaultValue in https://dotty.epfl.ch/docs/reference/metaprogramming/compiletime-ops.html
I can not make the example compile without adding the modifier transparent to transparent inline def defaultValue[T] = ...

val dInt: Some[Int] = defaultValue[Int]

[error] 5 |  val dInt: Some[Int] = defaultValue[Int]
[error]   |                        ^^^^^^^^^^^^^^^^^
[error]   |Found:    Option[Byte | Char | Short | Int | Long | Float | Double | Boolean | Unit]
[error]   |Required: Some[Int]

Am I interpreting this wrong or missing something?

Fabio Pinheiro
@FabioPinheiro
Ok this is compile-time supported for operations
I just don't know enough about metaprogramming in scala
Maybe this is the wrong channel to as questions
Dan Plyukhin
@dplyukhin
How can I test a Dotty plugin? I'd like to use DottyTest.checkCompile but I'm getting:
[error] 3 |import dotty.tools.DottyTest
[error]   |                   ^^^^^^^^^
[error]   |                   value DottyTest is not a member of dotty.tools
Guillaume Martres
@smarter
the test artifact isn't published
usually plugins are tested through sbt scripted tests
or just having a separate sub-project that uses the plugin
Swoorup Joshi
@Swoorup
Anyone seeing crashes like this?
java.lang.AssertionError: assertion failed: Attempt to commit TS[17264095X, 17263931X, 17263681X, 17263257X, 17262343, 17251978, 17251977, 17251976] into already committed TS[17263931X, 17263681X, 17263257X, 17262343, 17251978, 17251977, 17251976] while compiling /Users/swoorup.joshi/personal/zicoin/src/main/scala/Main.scala,
Getting an issue on 3.0.1
Try changing inline def decorateVals[A](output: ValDefInspection => Unit)(block: => A) to inline def decorateVals[A](output: ValDefInspection => Unit)(inline block: A)