Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

under -source:future, don't warn on infix usage of Scala 2 defined methods with default arguments #13714

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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