Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/bugPublic

-Wtostring-interpolated warns on an if expression of type String #13107

Open
scala/scala
#11074
Assignees
som-snytt
Labels
Milestone
@johnduffell

Description

@johnduffell

Reproduction steps

2.13.16
With scalacOptions including

    "-Wtostring-interpolated",

and optionally (to make it an error)

    "-Wconf:cat=w-flag-tostring-interpolated:e",

compile this code:

valshouldCaps=truevalgreeting=s"Hello${if (shouldCaps)"WORLD"else"world"}"println(greeting)

seehttps://scastie.scala-lang.org/MQWIvMVXSrCwU9u9D8NTCA

Output

there is a warning/error raised on line 2:
"interpolation uses toString"

Expectation

compiles without warnings, as the type of the expression is a String

Additional info

Also fails on 3.7.1-RC1
Feature introduced inscala/scala#10776

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp