Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Brice Jaglin
    @bjaglin
    you should be able to work around this with dependencyOverrides to bump the version of that transitive semanticdb-scalac
    Tim Spence
    @TimWSpence

    Thanks so much!!! Sorry my knowledge of sbt cross-building is painfully limited: you mean that version of scalacheck-effect-munit depends on semanticdb-scalac_2.13.3 instead of semanticdb_2.13? Would that be why 2.13.3 works but 2.13.4 doesn’t?

    And should scalacheck-effect-munit be depending on that at all out of curiosity? Thanks again!!

    Tomasz Godzik
    @tgodzik
    @TimWSpence not sure, but the current 0.6.0 version no longer depends on it, so I would recommend updating
    Tim Spence
    @TimWSpence
    Yeah, I was thinking I should check for another update :+1: thanks!
    and I can confirm that that does indeed work!!! :)
    Many, many thanks both
    Chris Kipp
    @ckipp:matrix.org
    [m]
    is there a way to specify the dialect with metac?
    basically I want to metac a Scala 3 file
    Ólafur Páll Geirsson
    @olafurpg
    @ckipp:matrix.org metac doesnt support scalac, but you shouldnt need it anyways because scala 3 has a -semanticdb flag
    metac is a thin wrapper around scalac that adds the -Xplugin:semanticdb.jar flag
    Chris Kipp
    @ckipp:matrix.org
    [m]
    yea I ask because I want to do something like dotty-repl -semanticdb src/main/scala/Main.sacla but that doesn't seemt to work, so I was curious if metac can just handle that to see the semanticdb a file produces
    but using the -semanticdb flag in this manner seems invalid when trying it
    Ólafur Páll Geirsson
    @olafurpg
    The flag may be -Xsemanticdb or something like that
    Did you try with dotc?
    Chris Kipp
    @ckipp:matrix.org
    [m]
    🤔 that doesn't seem to be the correct flag either
    dotty-repl is just the name coursier apps gives the latest scalac for Scala 3
    so it should be the same
    Ólafur Páll Geirsson
    @olafurpg
    ❯ scala3-compiler -Xsemanticdb foo.scala
    ❯ tree META-INF
    META-INF
    └── semanticdb
       └── foo.scala.semanticdb
    ❯ cs install scala3-compiler
    Chris Kipp
    @ckipp:matrix.org
    [m]
    huh, it looks like literally the only difference between dotty-repl and this is that one is explicit 3.0.0-RC1 and the other is latest but this works and the other doesn't
    thanks @olafurpg this is actually what I was looking for
    Ólafur Páll Geirsson
    @olafurpg
    It’s pretty cool that metac is redundant for scala 3!
    Chris Kipp
    @ckipp:matrix.org
    [m]
    yea it's cool that you can do this :)
    Anthony Holland
    @aholland

    Hi. I am looking for pointers on using scalameta with Scala 3. I have got as far as setting up a working Scala 3 project with a main module and a second module on which that depends (not currently relevant). I have declared a dependency on scala-meta using libraryDependencies += "org.scalameta" % "scalameta_2.13" % "4.4.10" and that works. I have some code to parse in a string as a Source and it parses successfully. I cannot match using QuasiQuotes because they have been dropped from Scala 3 (if I understand correctly). The code looks like this:

    import scala.meta._
    
    object Main {
     def main(args: Array[String]): Unit = {
      val program: String = """object Main extends App { print("Hello!") }"""
      val tree: Source = program.parse[Source].get
      println(tree) // => List(Hello World!)
      tree match {
       case Term.Name("Main") => println("Found1")
       case Term.Name("main") => println("Found2")
       case _ => println("Default only")
      }
      "".length // for breakpoint
     }
    
     def msg = "I was compiled by Scala 3. :)"
    
    }

    I am struggling to find a valid match criterion. Ultimately I would like to match on a case class and generate another case class from it. Specifically, I would like to read the list of fields and use that list to generate a similar case class in which each field's type is Option[ORIG_TYPE].

    Tomasz Godzik
    @tgodzik
    @aholland you can look for Defn.Class and check if mods contain Mod.Case
    Anthony Holland
    @aholland
    @tgodzik thanks. If I replace Term.Name("Main") with Defn.Class I still get no match. I feel like there might be some document I haven't read that I should have. Or am I almost there? Unfortunately I have to go now (time zone) but I would appreciate any answer in the morning.
    Tomasz Godzik
    @tgodzik
    there are a lot of examples in the parser and you can use .structure to see exactly how does the file look like
    for tree I would also go through .children method similar to how we do it in Metals
    Kasper Kondzielski
    @ghostbuster91
    Hi :)
    How do one assert that code generated with scala-meta is logically correct? For now I've been asserting against expected version of file using source.structure for making comparison, but the output in case of miss-match is hard to read. On the other hand I cannot compare them as strings as they have different formatting. Is there anything which I missed?
    Kasper Kondzielski
    @ghostbuster91
    Hmm, I suppose that I can compare them as strings after after parsing the expected file with scala-meta as it looses all the formatting. Would that be a correct way to do?
    Tomasz Godzik
    @tgodzik
    @ghostbuster91 we usually reparse the file to see if the AST changed, if it didn't it means we're fine
    how are you generating the source actually? Just to make sure your particular use case is supported
    1 reply
    Kasper Kondzielski
    @ghostbuster91
    Thanks, I was just looking for exactly that code :)
    Sakib Hadžiavdić
    @sake92
    Hello! How can I test if a class is annotated with a specific annotation?
    The structure is different when using @abc and @x.y.abc..
    Tomasz Godzik
    @tgodzik
    @sake92 I think it you're doing it from the parser then it should have additional mod
    Mod.Annot
    Sakib Hadžiavdić
    @sake92
    @tgodzik yeah. But it's hard to test for FQN. Nevermind, I'll go with simplest solution. YOLO :smile:
    trying to migrate Wither generator to scalafix: https://github.com/sake92/stone#wither
    Tomasz Godzik
    @tgodzik
    @sake92 scalafix usually applies rules on the existing code to change it , not sure how you can use that for wither :thinking:
    or do you plan to refactor this class by adding the methods explicitely?
    Sakib Hadžiavdić
    @sake92
    yeah, just add them explicitly, if they're missing in source
    Tomasz Godzik
    @tgodzik
    ach ok, that makes sense. Please do add the scalafix rule to https://scalacenter.github.io/scalafix/docs/rules/community-rules.html if you manage to get it working!
    Sakib Hadžiavdić
    @sake92
    sure, thanks! :)
    Igal Tabachnik
    @hmemcpy
    Hi all! I'm trying to figure out how to render extension methods "as-is". I am calling showCode on a Select node of an expression e.g. obj.someExtension, but it shows up as MyExt(obj).someExtension. Would appreciate any hints whether it's possible to have it print as obj.someExtension instead?
    Hmm, this is done from a macro on a scala.reflect.api, if that matters... perhaps I should ask this in scala/scala instead?
    Ólafur Páll Geirsson
    @olafurpg
    @hmemcpy scala/scala or scala/contributors is a better place to ask
    Igal Tabachnik
    @hmemcpy
    Cheers. Will try there!