Code Monkey home page Code Monkey logo

Comments (12)

SethTisue avatar SethTisue commented on July 18, 2024

@som-snytt not obvious me to what the cause might be. I'll keep digging.

from community-build.

som-snytt avatar som-snytt commented on July 18, 2024

[warn] 1 deprecation (since 18); re-run with -deprecation for details

I think this is our first time seeing Java since.

Nice comment is cold comfort:

  * NOTE(olafurpg). The pattern match in this file has gotten out of hand. It's
  * difficult even for myself to keep track of what's going on

It turns out that Scalameta has (where IndexedSeqOptimized is a dummy trait for 2.13)

@data class Tokens private (
    private val tokens: Array[Token],
    private val start: Int,
    private val end: Int
) extends immutable.IndexedSeq[Token] with IndexedSeqOptimized[Token] {
  def apply(idx: Int): Token = tokens(start + idx)
  def length: Int = end - start

head is defined as apply(0) (the old implementation) and last is inherited, which used to be apply(length-1) but now checks isEmpty first. Since start is typically an index into the large tokens array, apply(-1) does not throw but generally supplies a scala.meta.tokens.Token$Space.

Probably that is just a bug in Scalameta, and the additional bug in Scalafmt is not to assume non-empty tokens (see added filter):

defnBeforeTemplate(leftOwner).filter(_.tokens.nonEmpty).map { x =>
  val policyEnd = Policy.End.On(x.tokens.last)
  delayedBreakPolicy(policyEnd)(forceNewlineBeforeExtends)
}

or what have you.

For a while, I assumed the problem would be brittle inheritance in IndexedSeq, which may still be an issue. Not sure if the following comment just means compatibility between 2.12 and 2.13, etc.

  /* Both head and headOption need to be implemented here due to
   * binary incompatibility caused by
   * https://github.com/scala/scala/commit/b20dd00b11f06c14c823d277cdfb58043a2586fc
   */
  override def head: Token = apply(0)

from community-build.

SethTisue avatar SethTisue commented on July 18, 2024

Jenkins is currently chewing on the sbt 1.9.1->2 upgrade. after that, #1681 should get us to where we would be able to pull in a Scalameta fix

fyi @kitbellew

from community-build.

SethTisue avatar SethTisue commented on July 18, 2024

@lrytz does this give you cold feet about scala/scala#10392 ?

while you ponder that, I'll try making Som's suggested changes in scalacommunitybuild forks of scalameta and scalafmt.

from community-build.

som-snytt avatar som-snytt commented on July 18, 2024

@SethTisue revealing bugs in library code is a good thing. I'm using "good thing" in its generic, non-trademarked sense.

from community-build.

SethTisue avatar SethTisue commented on July 18, 2024

ah, @som-snytt is way ahead of me... I'm just now seeing scalameta/scalameta#3235 and scalameta/scalafmt#3581. I'll give those a try

from community-build.

SethTisue avatar SethTisue commented on July 18, 2024

yup that did it 🎉 , thx @som-snytt

from community-build.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.