From 790051e6d4cca04c22cf6ab6d640f0459ad3dbb0 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 13 Mar 2023 15:39:19 +0100 Subject: [PATCH] Fix isJavaOverride test Fixes #17066 --- compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala | 3 ++- tests/pos/i17066/Bar.scala | 2 ++ tests/pos/i17066/Foo.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i17066/Bar.scala create mode 100644 tests/pos/i17066/Foo.java diff --git a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala index 78baec70bee6..359b882ef26b 100644 --- a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala +++ b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala @@ -87,7 +87,8 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase => * signatures of a Java varargs method and a Scala varargs override are not the same. */ private def overridesJava(sym: Symbol)(using Context) = - sym.owner.info.baseClasses.drop(1).exists { bc => + sym.memberCanMatchInheritedSymbols + && sym.owner.info.baseClasses.drop(1).exists { bc => bc.is(JavaDefined) && { val other = bc.info.nonPrivateDecl(sym.name) other.hasAltWith { alt => diff --git a/tests/pos/i17066/Bar.scala b/tests/pos/i17066/Bar.scala new file mode 100644 index 000000000000..7d3e67f85387 --- /dev/null +++ b/tests/pos/i17066/Bar.scala @@ -0,0 +1,2 @@ +class Bar extends Foo: + def this(xs: String*) = this() diff --git a/tests/pos/i17066/Foo.java b/tests/pos/i17066/Foo.java new file mode 100644 index 000000000000..cb4335c7d444 --- /dev/null +++ b/tests/pos/i17066/Foo.java @@ -0,0 +1,3 @@ +public class Foo { + public Foo(String... xs) { } +}