Skip to content

Commit 583a5e5

Browse files
authored
Merge pull request #13714 from SethTisue/issue-10383
under -source:future, don't warn on infix usage of Scala 2 defined methods with default arguments
2 parents c27107b + aba4d2c commit 583a5e5

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2678,7 +2678,10 @@ class Typer extends Namer
26782678
wrapDefs(defs, lift(app))
26792679
else app
26802680
}
2681-
checkValidInfix(tree, result.symbol)
2681+
// issue 10383: we stripBlock because e.g. default arguments desugar to blocks during typing,
2682+
// and the block itself doesn't have a symbol (because a Block isn't a ProxyTree),
2683+
// but the last expression in the block does have the right symbol
2684+
checkValidInfix(tree, stripBlock(result).symbol)
26822685
result
26832686
}
26842687

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class CompilationTests {
6262
compileFile("tests/pos-custom-args/i9267.scala", defaultOptions.and("-Ystop-after:erasure")),
6363
compileFile("tests/pos-special/extend-java-enum.scala", defaultOptions.and("-source", "3.0-migration")),
6464
compileFile("tests/pos-custom-args/help.scala", defaultOptions.and("-help", "-V", "-W", "-X", "-Y")),
65+
compileFile("tests/pos-custom-args/i10383.scala", defaultOptions.and("-source", "future", "-deprecation", "-Xfatal-warnings")),
6566
).checkCompile()
6667
}
6768

tests/pos-custom-args/i10383.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def r = BigInt(1) to BigInt(3) // error

0 commit comments

Comments
 (0)