Skip to content

Commit

Permalink
also cook the tree of a java raw type
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Feb 21, 2024
1 parent 3ab2999 commit e8e295a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4275,14 +4275,16 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
val tree1 =
if ((pt eq AnyTypeConstructorProto) || tp.typeParamSymbols.isEmpty) tree
else {
val tp1 =
if (ctx.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.isJava)
// Cook raw type
val typeArgs = tp.typeParams.map(Function.const(TypeBounds.empty))
val tree1 = AppliedTypeTree(tree, typeArgs.map(TypeTree(_)))
val tp1 = AppliedType(tree.tpe, typeArgs)
tree1.withType(tp1)
else
// Eta-expand higher-kinded type
val tp1 = tree.tpe.etaExpand(tp.typeParamSymbols)
tree.withType(tp1)
}
if (ctx.mode.is(Mode.Pattern) || ctx.mode.isQuotedPattern || tree1.tpe <:< pt) tree1
else err.typeMismatch(tree1, pt)
Expand Down
2 changes: 1 addition & 1 deletion sbt-test/pipelining/Yjava-tasty-paths/b/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object B {
val cd_ii_Raw: RawTypes#C[?]#D[?] = cd_ii

RawTypes.mii_Raw_Raw(cd_ii_Raw)
// RawTypes.mii_Raw_Raw2(cd_ii_Raw) // error: dotty still doesnt rewrite the tree of a raw type to a type with wildcards
RawTypes.mii_Raw_Raw2(cd_ii_Raw)
}
}

Expand Down

0 comments on commit e8e295a

Please sign in to comment.