From 75f8212beb4249543f6a0dbf9f7ca2ca5fb93cc3 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Fri, 17 Nov 2023 10:35:35 +0100 Subject: [PATCH 1/4] Add test --- tests/pos/i18654/AbstractQueryPart.java | 9 +++++++++ tests/pos/i18654/AbstractRoutine.java | 11 +++++++++++ tests/pos/i18654/Attachable.java | 5 +++++ tests/pos/i18654/Configuration.java | 3 +++ tests/pos/i18654/MyRoutineScala.scala | 6 ++++++ 5 files changed, 34 insertions(+) create mode 100644 tests/pos/i18654/AbstractQueryPart.java create mode 100644 tests/pos/i18654/AbstractRoutine.java create mode 100644 tests/pos/i18654/Attachable.java create mode 100644 tests/pos/i18654/Configuration.java create mode 100644 tests/pos/i18654/MyRoutineScala.scala diff --git a/tests/pos/i18654/AbstractQueryPart.java b/tests/pos/i18654/AbstractQueryPart.java new file mode 100644 index 000000000000..d56e0820982a --- /dev/null +++ b/tests/pos/i18654/AbstractQueryPart.java @@ -0,0 +1,9 @@ +package org.jooq.impl; + +import org.jooq.Configuration; + +abstract class AbstractQueryPart { + Configuration configuration() { + return null; + } +} diff --git a/tests/pos/i18654/AbstractRoutine.java b/tests/pos/i18654/AbstractRoutine.java new file mode 100644 index 000000000000..ea8a56c3395e --- /dev/null +++ b/tests/pos/i18654/AbstractRoutine.java @@ -0,0 +1,11 @@ +package org.jooq.impl; + +import org.jooq.Configuration; +import org.jooq.Attachable; + +public abstract class AbstractRoutine extends AbstractQueryPart implements Attachable { + @Override + public final Configuration configuration() { + return null; + } +} diff --git a/tests/pos/i18654/Attachable.java b/tests/pos/i18654/Attachable.java new file mode 100644 index 000000000000..2b458af120bc --- /dev/null +++ b/tests/pos/i18654/Attachable.java @@ -0,0 +1,5 @@ +package org.jooq; + +public interface Attachable { + Configuration configuration(); +} diff --git a/tests/pos/i18654/Configuration.java b/tests/pos/i18654/Configuration.java new file mode 100644 index 000000000000..0dd97aed6730 --- /dev/null +++ b/tests/pos/i18654/Configuration.java @@ -0,0 +1,3 @@ +package org.jooq; + +public interface Configuration {} \ No newline at end of file diff --git a/tests/pos/i18654/MyRoutineScala.scala b/tests/pos/i18654/MyRoutineScala.scala new file mode 100644 index 000000000000..088f18e92741 --- /dev/null +++ b/tests/pos/i18654/MyRoutineScala.scala @@ -0,0 +1,6 @@ +package com.example + +import org.jooq.impl.AbstractRoutine + +// Works in Scala 2.12 and 2.13 but is broken in Scala 3 +class MyRoutineScala extends AbstractRoutine[String] {} From 0f2f9f9c0a8836540682e99ef66bf44fb10b141d Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Fri, 17 Nov 2023 12:20:35 +0100 Subject: [PATCH 2/4] Exclude override checks for pairs from a Java class parent --- compiler/src/dotty/tools/dotc/typer/RefChecks.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 4f0ec6a6bcdc..5e114fa7534b 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -224,6 +224,9 @@ object RefChecks { * See neg/i12828.scala for an example where this matters. * - They overriding/overridden appear in linearization order. * See neg/i5094.scala for an example where this matters. + * - They overriding/overridden appear in linearization order, + * or the parent is a Java class (because linearization does not apply to java classes). + * See neg/i5094.scala and pos/i18654.scala for examples where this matters. * - The overridden symbol is not `abstract override`. For such symbols * we need a more extensive test since the virtual super chain depends * on the precise linearization order, which might be different for the @@ -232,7 +235,7 @@ object RefChecks { override def canBeHandledByParent(sym1: Symbol, sym2: Symbol, parent: Symbol): Boolean = isOverridingPair(sym1, sym2, parent.thisType) .showing(i"already handled ${sym1.showLocated}: ${sym1.asSeenFrom(parent.thisType).signature}, ${sym2.showLocated}: ${sym2.asSeenFrom(parent.thisType).signature} = $result", refcheck) - && inLinearizationOrder(sym1, sym2, parent) + && (inLinearizationOrder(sym1, sym2, parent) || parent.is(JavaDefined)) && !sym2.is(AbsOverride) /** Checks the subtype relationship tp1 <:< tp2. From b61e01013ed78f85ffc382feb1c6aa8990b829fc Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Sat, 25 Nov 2023 16:45:16 +0100 Subject: [PATCH 3/4] Add test from i19007 --- tests/pos/i19007/MyRunConfigurationScala.scala | 2 ++ tests/pos/i19007/RunConfiguration.java | 4 ++++ tests/pos/i19007/RunConfigurationBase.java | 6 ++++++ tests/pos/i19007/UserDataHolderBase.java | 8 ++++++++ 4 files changed, 20 insertions(+) create mode 100644 tests/pos/i19007/MyRunConfigurationScala.scala create mode 100644 tests/pos/i19007/RunConfiguration.java create mode 100644 tests/pos/i19007/RunConfigurationBase.java create mode 100644 tests/pos/i19007/UserDataHolderBase.java diff --git a/tests/pos/i19007/MyRunConfigurationScala.scala b/tests/pos/i19007/MyRunConfigurationScala.scala new file mode 100644 index 000000000000..3ce74344cc8b --- /dev/null +++ b/tests/pos/i19007/MyRunConfigurationScala.scala @@ -0,0 +1,2 @@ + +class MyRunConfigurationScala extends RunConfigurationBase diff --git a/tests/pos/i19007/RunConfiguration.java b/tests/pos/i19007/RunConfiguration.java new file mode 100644 index 000000000000..ee67eb4f6c89 --- /dev/null +++ b/tests/pos/i19007/RunConfiguration.java @@ -0,0 +1,4 @@ + +public interface RunConfiguration extends Cloneable { + RunConfiguration clone(); +} \ No newline at end of file diff --git a/tests/pos/i19007/RunConfigurationBase.java b/tests/pos/i19007/RunConfigurationBase.java new file mode 100644 index 000000000000..410c625c746f --- /dev/null +++ b/tests/pos/i19007/RunConfigurationBase.java @@ -0,0 +1,6 @@ +public abstract class RunConfigurationBase extends UserDataHolderBase implements RunConfiguration { + @Override + public RunConfiguration clone() { + return null; + } +} \ No newline at end of file diff --git a/tests/pos/i19007/UserDataHolderBase.java b/tests/pos/i19007/UserDataHolderBase.java new file mode 100644 index 000000000000..a91607086761 --- /dev/null +++ b/tests/pos/i19007/UserDataHolderBase.java @@ -0,0 +1,8 @@ +import java.util.concurrent.atomic.AtomicReference; + +public class UserDataHolderBase extends AtomicReference { + @Override + protected Object clone() { + return null; + } +} From 520ad661eb1a6be2f636906d890329309345aa10 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Sun, 26 Nov 2023 11:55:35 +0100 Subject: [PATCH 4/4] Add test from i18764 --- sbt-test/java-compat/i18764/Test.scala | 4 ++++ sbt-test/java-compat/i18764/build.sbt | 9 +++++++++ sbt-test/java-compat/i18764/test | 1 + 3 files changed, 14 insertions(+) create mode 100644 sbt-test/java-compat/i18764/Test.scala create mode 100644 sbt-test/java-compat/i18764/build.sbt create mode 100644 sbt-test/java-compat/i18764/test diff --git a/sbt-test/java-compat/i18764/Test.scala b/sbt-test/java-compat/i18764/Test.scala new file mode 100644 index 000000000000..030afb46b953 --- /dev/null +++ b/sbt-test/java-compat/i18764/Test.scala @@ -0,0 +1,4 @@ + +import org.jooq.impl.TableRecordImpl + +class TRecord extends TableRecordImpl[TRecord](null) {} diff --git a/sbt-test/java-compat/i18764/build.sbt b/sbt-test/java-compat/i18764/build.sbt new file mode 100644 index 000000000000..2ad74478d52b --- /dev/null +++ b/sbt-test/java-compat/i18764/build.sbt @@ -0,0 +1,9 @@ + +scalaVersion := sys.props("plugin.scalaVersion") + +lazy val dependencies = Seq( + "org.jooq" % "jooq-codegen" % "3.18.7", +) + +lazy val jooqtest = (project in file(".")) + .settings(libraryDependencies ++= dependencies) diff --git a/sbt-test/java-compat/i18764/test b/sbt-test/java-compat/i18764/test new file mode 100644 index 000000000000..5df2af1f3956 --- /dev/null +++ b/sbt-test/java-compat/i18764/test @@ -0,0 +1 @@ +> compile