scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Field named `StringContext` followed by `s""` does not compile #12789

Closed izzyreal closed 1 year ago

izzyreal commented 1 year ago

Reproduction steps

Scala version: 2.13.10

scala> class Foo { val StringContext = 42; s"" }

Problem

The above code does not compile in 2.13.10 (though it compiles in 3.2.2). If you change the name of the field it compiles in 2.13.10.

som-snytt commented 1 year ago

It was intentional in Scala 2 that interpolation used a locally scoped identifier StringContext, but that behavior was changed, intentionally, in Scala 3.

SethTisue commented 1 year ago

The above code does not compile in 2.13.10

For the record, the error is "error: Int does not take parameters; signature for interpolation must be StringContext.apply(String*)"

izzyreal commented 1 year ago

Thanks for the amendment @SethTisue 👍

som-snytt commented 1 year ago

What a nice error message from the beginning of the pandemic.