Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in large string interpolations with non-String typed splices #8315

Merged
merged 1 commit into from Aug 13, 2019

Conversation

retronym
Copy link
Member

@retronym retronym commented Aug 6, 2019

@scala-jenkins scala-jenkins added this to the 2.12.10 milestone Aug 6, 2019
@retronym retronym requested a review from adriaanm August 6, 2019 00:38
test(125, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
test(126, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
test(127, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
test(128, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If scalacenter ran an annual "christmas tree of code" contest, it might help guard against regressions like this.

Crowdsource the test!

Copy link
Member Author

@retronym retronym Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        test(1, s"$a")//  ~~~          | WHEEEE | 
        test(2, s"$a$a") //   ~~  #    /
        test(3, s"$a$a$a") //      @ /
        test(4, s"$a$a$a$a") //   _/\\
        test(5, s"$a$a$a$a$a") //    \\
        test(6, s"$a$a$a$a$a$a") //  ~~~~
        test(7, s"$a$a$a$a$a$a$a")
        test(8, s"$a$a$a$a$a$a$a$a")
        test(9, s"$a$a$a$a$a$a$a$a$a")
        test(10, s"$a$a$a$a$a$a$a$a$a$a")
        test(11, s"$a$a$a$a$a$a$a$a$a$a$a")
        test(12, s"$a$a$a$a$a$a$a$a$a$a$a$a")
        test(13, s"$a$a$a$a$a$a$a$a$a$a$a$a$a")
        test(14, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
        test(15, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
        test(16, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")
        test(17, s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a")

?

@adriaanm
Copy link
Contributor

adriaanm commented Aug 6, 2019

@ShaneDelmore
Copy link
Contributor

This issue breaks a number of projects in the Twitter code base preventing us from upgrading to 2.12.9. Will this PR merit a hotfix release?

@SethTisue
Copy link
Member

1 test failure

went away on /rebuild

@som-snytt
Copy link
Contributor

The test doesn't compile under 2.13.

error: Error while emitting t11665/Test$
Method too large: t11665/Test$.main ([Ljava/lang/String;)V

@Ichoran
Copy link
Contributor

Ichoran commented Aug 7, 2019

Why is the test file indented with four-space indents?

Also, making each interpolation its own def would fix the method size problem.

def mkDef(n: Int) = "  def mk" + n.toString + " = \"" + "$a"*n + "\""
def mkTest(n: Int) = s"    test($n, mk$n)"

@retronym
Copy link
Member Author

retronym commented Aug 7, 2019

I've tweaked the test to fix indentation and avoid the large method size.

@som-snytt
Copy link
Contributor

I was curious why 2.13 switches to fallback mode after 64. I'm too tired to think about that, but I did just do the Scalafix tutorial:

class String32 extends SemanticRule("String32") {

  override def fix(implicit doc: SemanticDocument): Patch = {
    doc.tree
      .collect { 
        case t @ Term.Interpolate(prefix @ Term.Name("s"), parts @ _, args) if args.length > 32 =>
          args.zipWithIndex.collect {
            case (arg, i) if i % 32 == 0 => Patch.addLeft(arg, "{") + Patch.addRight(arg, ".toString()}")
          }
      }
      .flatten
      .asPatch
  }
}

@retronym retronym force-pushed the ticket/11665 branch 2 times, most recently from 55308dc to cccc4d1 Compare August 8, 2019 02:11
@SethTisue
Copy link
Member

SethTisue commented Aug 9, 2019

Will this PR merit a hotfix release?

Seems likely, depending on how hot “hot” is. We'll discuss at the next Scala team meeting. (for further discussion on 2.12.10 timing and contents, better to open a https://contributors.scala-lang.org thread)

@retronym retronym merged commit e9ea55f into scala:2.12.x Aug 13, 2019
@som-snytt
Copy link
Contributor

If only folks running sbz, which would be sbt married to sbaz, could auto-download a hot scalafix that would run during their next build.

@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
9 participants