@@ -2007,15 +2007,19 @@ object Parsers {
20072007 Ident (tpnme.USCOREkw ).withSpan(Span (start, in.lastOffset, start))
20082008 else
20092009 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 )
20172013 val start = in.skipToken()
20182014 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+
20192023 // Allow symbols -_ and +_ through for compatibility with code written using kind-projector in Scala 3 underscore mode.
20202024 // While these signify variant type parameters in Scala 2 + kind-projector, we ignore their variance markers since variance is inferred.
20212025 else if (isIdent(nme.MINUS ) || isIdent(nme.PLUS )) && in.lookahead.token == USCORE && ctx.settings.XkindProjector .value == " underscores" then
0 commit comments