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

Don't check bounds of Java applications in Java units #18054

Merged
merged 2 commits into from
Jun 26, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ object Checking {
val checker = new TypeTraverser:
def traverse(tp: Type) =
tp match
case AppliedType(tycon, argTypes) =>
case AppliedType(tycon, argTypes)
if !(tycon.typeSymbol.is(JavaDefined) && ctx.compilationUnit.isJava) =>
// Don't check bounds in Java units that refer to Java type constructors.
// Scala is not obliged to do Java type checking and in fact i17763 goes wrong
// if we attempt to check bounds of F-bounded mutually recursive Java interfaces.
// Do check all bounds in Scala units and those bounds in Java units that
// occur in applications of Scala type constructors.
checkAppliedType(
untpd.AppliedTypeTree(TypeTree(tycon), argTypes.map(TypeTree(_)))
.withType(tp).withSpan(tpt.span.toSynthetic),
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/i17763/CopyableBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public interface CopyableBuilder<B extends CopyableBuilder<B, T>, T extends ToCopyableBuilder<B, T>> {
}
1 change: 1 addition & 0 deletions tests/pos/i17763/Crash.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Crash
2 changes: 2 additions & 0 deletions tests/pos/i17763/ToCopyableBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public interface ToCopyableBuilder<B extends CopyableBuilder<B, T>, T extends ToCopyableBuilder<B, T>> {
}