From 532f1642d4fdcd559d21003efdeff699441b2278 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 11 Jan 2018 16:50:49 +0100 Subject: [PATCH 1/2] Fix #3807: Handle selection on raw Java type They should be fully-applied with wildcards, not eta-expanded. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 11 ++++++++++- tests/pos-java-interop/selectOnRaw/Test.java | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/pos-java-interop/selectOnRaw/Test.java diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index c9458c547aec..3addf72b2d73 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2370,7 +2370,16 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def adaptType(tp: Type): Tree = { val tree1 = if ((pt eq AnyTypeConstructorProto) || tp.typeParamSymbols.isEmpty) tree - else tree.withType(tree.tpe.EtaExpand(tp.typeParamSymbols)) + else { + val tp1 = + if (ctx.compilationUnit.isJava) + // Cook raw type + AppliedType(tree.tpe, tp.typeParams.map(Function.const(TypeBounds.empty))) + else + // Eta-expand higher-kinded type + tree.tpe.EtaExpand(tp.typeParamSymbols) + tree.withType(tp1) + } if ((ctx.mode is Mode.Pattern) || tree1.tpe <:< pt) tree1 else err.typeMismatch(tree1, pt) } diff --git a/tests/pos-java-interop/selectOnRaw/Test.java b/tests/pos-java-interop/selectOnRaw/Test.java new file mode 100644 index 000000000000..b30b3acaa21e --- /dev/null +++ b/tests/pos-java-interop/selectOnRaw/Test.java @@ -0,0 +1,9 @@ +public class Test { + public Outer.Inner foo() { + return null; + } +} + +class Outer { + class Inner {} +} From 9f762ccf8a516a19d39023213aa3b0887f84c8c2 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 11 Jan 2018 16:52:54 +0100 Subject: [PATCH 2/2] Enable all pending java-interop tests --- .../pos/java-interop => pos-java-interop/t1263}/t1263/Test.java | 0 .../pos/java-interop => pos-java-interop/t1263}/t1263/test.scala | 0 tests/{pending/pos/java-interop => pos-java-interop}/t1745/J.java | 0 .../{pending/pos/java-interop => pos-java-interop}/t1745/S.scala | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/{pending/pos/java-interop => pos-java-interop/t1263}/t1263/Test.java (100%) rename tests/{pending/pos/java-interop => pos-java-interop/t1263}/t1263/test.scala (100%) rename tests/{pending/pos/java-interop => pos-java-interop}/t1745/J.java (100%) rename tests/{pending/pos/java-interop => pos-java-interop}/t1745/S.scala (100%) diff --git a/tests/pending/pos/java-interop/t1263/Test.java b/tests/pos-java-interop/t1263/t1263/Test.java similarity index 100% rename from tests/pending/pos/java-interop/t1263/Test.java rename to tests/pos-java-interop/t1263/t1263/Test.java diff --git a/tests/pending/pos/java-interop/t1263/test.scala b/tests/pos-java-interop/t1263/t1263/test.scala similarity index 100% rename from tests/pending/pos/java-interop/t1263/test.scala rename to tests/pos-java-interop/t1263/t1263/test.scala diff --git a/tests/pending/pos/java-interop/t1745/J.java b/tests/pos-java-interop/t1745/J.java similarity index 100% rename from tests/pending/pos/java-interop/t1745/J.java rename to tests/pos-java-interop/t1745/J.java diff --git a/tests/pending/pos/java-interop/t1745/S.scala b/tests/pos-java-interop/t1745/S.scala similarity index 100% rename from tests/pending/pos/java-interop/t1745/S.scala rename to tests/pos-java-interop/t1745/S.scala