Skip to content

Commit 532f164

Browse files
committed
Fix #3807: Handle selection on raw Java type
They should be fully-applied with wildcards, not eta-expanded.
1 parent f595a1a commit 532f164

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,16 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
23702370
def adaptType(tp: Type): Tree = {
23712371
val tree1 =
23722372
if ((pt eq AnyTypeConstructorProto) || tp.typeParamSymbols.isEmpty) tree
2373-
else tree.withType(tree.tpe.EtaExpand(tp.typeParamSymbols))
2373+
else {
2374+
val tp1 =
2375+
if (ctx.compilationUnit.isJava)
2376+
// Cook raw type
2377+
AppliedType(tree.tpe, tp.typeParams.map(Function.const(TypeBounds.empty)))
2378+
else
2379+
// Eta-expand higher-kinded type
2380+
tree.tpe.EtaExpand(tp.typeParamSymbols)
2381+
tree.withType(tp1)
2382+
}
23742383
if ((ctx.mode is Mode.Pattern) || tree1.tpe <:< pt) tree1
23752384
else err.typeMismatch(tree1, pt)
23762385
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Test {
2+
public Outer.Inner foo() {
3+
return null;
4+
}
5+
}
6+
7+
class Outer<A> {
8+
class Inner {}
9+
}

0 commit comments

Comments
 (0)