@@ -2007,15 +2007,19 @@ object Parsers {
2007
2007
Ident (tpnme.USCOREkw ).withSpan(Span (start, in.lastOffset, start))
2008
2008
else
2009
2009
if ! inMatchPattern then
2010
- report.errorOrMigrationWarning(
2011
- em " `_` is deprecated for wildcard arguments of types: use `?` instead ${rewriteNotice(`3.4-migration`)}" ,
2012
- in.sourcePos(),
2013
- MigrationVersion .WildcardType )
2014
- if MigrationVersion .WildcardType .needsPatch then
2015
- patch(source, Span (in.offset, in.offset + 1 ), " ?" )
2016
- end if
2010
+ val msg =
2011
+ em " `_` is deprecated for wildcard arguments of types: use `?` instead ${rewriteNotice(`3.4-migration`)}"
2012
+ report.errorOrMigrationWarning(msg, in.sourcePos(), MigrationVersion .WildcardType )
2017
2013
val start = in.skipToken()
2018
2014
typeBounds().withSpan(Span (start, in.lastOffset, start))
2015
+ .tap: tbt =>
2016
+ if ! inMatchPattern && MigrationVersion .WildcardType .needsPatch then
2017
+ val offset_? = tbt.span.start
2018
+ if Chars .isOperatorPart(source(offset_? + 1 )) then
2019
+ patch(source, tbt.span, " ?" + ctx.printer.toText(tbt).mkString())
2020
+ else
2021
+ patch(source, Span (offset_?, offset_? + 1 ), " ?" )
2022
+
2019
2023
// Allow symbols -_ and +_ through for compatibility with code written using kind-projector in Scala 3 underscore mode.
2020
2024
// While these signify variant type parameters in Scala 2 + kind-projector, we ignore their variance markers since variance is inferred.
2021
2025
else if (isIdent(nme.MINUS ) || isIdent(nme.PLUS )) && in.lookahead.token == USCORE && ctx.settings.XkindProjector .value == " underscores" then
0 commit comments