aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-03-11 16:19:31 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-03-12 13:28:27 +0100
commite5e691ea2dd53abb64306b91bf172aaa8e2e6b9c (patch)
treebc6de92440d037bc9e080f97df9c4ff8de025040 /compiler/src/dotty/tools/dotc/typer/RefChecks.scala
parentb2d3b8938391516e81f18962e67f5bacf0aa2440 (diff)
downloaddotty-e5e691ea2dd53abb64306b91bf172aaa8e2e6b9c.tar.gz
dotty-e5e691ea2dd53abb64306b91bf172aaa8e2e6b9c.tar.bz2
dotty-e5e691ea2dd53abb64306b91bf172aaa8e2e6b9c.zip
Fix overriding a Java method with varargs
If A method like: override def foo(x: Object*) overrides a Java method, it needs to be rewritten as: def foo(x: Seq[Object]) override def foo(x: Array[Object]): Object = foo(Predef.wrapRefArray(x)) This should be handled by ElimRepeated but there were two bugs: - `addVarArgsBridge` was called at phase `thisTransformer.next`, this is too late to create the bridge since `T*` has already been rewritten as `Seq[T]` - The original method symbol needs to have the `override` flag dropped, since it doesn't override anything. Furthermore, RefChecks had to be moved after ElimRepeated, otherwise the testcase would fail the overriding checks.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/RefChecks.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/RefChecks.scala3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
index 23d05e087..e8ff7d572 100644
--- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
+++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
@@ -766,6 +766,9 @@ class RefChecks extends MiniPhase { thisTransformer =>
override def phaseName: String = "refchecks"
+ // Needs to run after ElimRepeated for override checks involving varargs methods
+ override def runsAfter = Set(classOf[ElimRepeated])
+
val treeTransform = new Transform(NoLevelInfo)
class Transform(currentLevel: RefChecks.OptLevelInfo = RefChecks.NoLevelInfo) extends TreeTransform {