Skip to content

Commit

Permalink
don't warn on infix usage of Scala 2 defined methods
Browse files Browse the repository at this point in the history
fixes scala#10383

Co-authored-by: Dale Wijnand <[email protected]>
  • Loading branch information
SethTisue and dwijnand committed Oct 13, 2021
1 parent d3a26e2 commit aba4d2c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,10 @@ class Typer extends Namer
wrapDefs(defs, lift(app))
else app
}
checkValidInfix(tree, result.symbol)
// issue 10383: we stripBlock because e.g. default arguments desugar to blocks during typing,
// and the block itself doesn't have a symbol (because a Block isn't a ProxyTree),
// but the last expression in the block does have the right symbol
checkValidInfix(tree, stripBlock(result).symbol)
result
}

Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CompilationTests {
compileFile("tests/pos-custom-args/i9267.scala", defaultOptions.and("-Ystop-after:erasure")),
compileFile("tests/pos-special/extend-java-enum.scala", defaultOptions.and("-source", "3.0-migration")),
compileFile("tests/pos-custom-args/help.scala", defaultOptions.and("-help", "-V", "-W", "-X", "-Y")),
compileFile("tests/pos-custom-args/i10383.scala", defaultOptions.and("-source", "future", "-deprecation", "-Xfatal-warnings")),
).checkCompile()
}

Expand Down
1 change: 1 addition & 0 deletions tests/pos-custom-args/i10383.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def r = BigInt(1) to BigInt(3) // error

0 comments on commit aba4d2c

Please sign in to comment.