Skip to content

Commit df85625

Browse files
authored
Merge pull request #3809 from dotty-staging/fix-select-on-raw
Fix #3807: Handle selection on raw Java type
2 parents f89b050 + 9f762cc commit df85625

File tree

6 files changed

+19
-1
lines changed

6 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
@@ -2377,7 +2377,16 @@ class Typer extends Namer
23772377
def adaptType(tp: Type): Tree = {
23782378
val tree1 =
23792379
if ((pt eq AnyTypeConstructorProto) || tp.typeParamSymbols.isEmpty) tree
2380-
else tree.withType(tree.tpe.EtaExpand(tp.typeParamSymbols))
2380+
else {
2381+
val tp1 =
2382+
if (ctx.compilationUnit.isJava)
2383+
// Cook raw type
2384+
AppliedType(tree.tpe, tp.typeParams.map(Function.const(TypeBounds.empty)))
2385+
else
2386+
// Eta-expand higher-kinded type
2387+
tree.tpe.EtaExpand(tp.typeParamSymbols)
2388+
tree.withType(tp1)
2389+
}
23812390
if ((ctx.mode is Mode.Pattern) || tree1.tpe <:< pt) tree1
23822391
else err.typeMismatch(tree1, pt)
23832392
}
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)