Skip to content

Commit d3e5a69

Browse files
committed
Merge pull request #901 from dotty-staging/fix-#851
Fix #851 Java parsing forgot type parameters
2 parents c9eba1e + e1586bc commit d3e5a69

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ object JavaParsers {
114114

115115
def makeTemplate(parents: List[Tree], stats: List[Tree], tparams: List[TypeDef], needsDummyConstr: Boolean) = {
116116
def pullOutFirstConstr(stats: List[Tree]): (Tree, List[Tree]) = stats match {
117-
case (meth: DefDef) :: rest if meth.name.isConstructorName => (meth, rest)
117+
case (meth: DefDef) :: rest if meth.name == CONSTRUCTOR => (meth, rest)
118118
case first :: rest =>
119119
val (constr, tail) = pullOutFirstConstr(rest)
120120
(constr, first :: tail)

src/dotty/tools/dotc/typer/FrontEnd.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class FrontEnd extends Phase {
2828
unit.untpdTree =
2929
if (unit.isJava) new JavaParser(unit.source).parse()
3030
else new Parser(unit.source).parse()
31-
typr.println("parsed:\n" + unit.untpdTree.show)
31+
val printer = if (ctx.settings.Xprint.value.contains("parser")) default else typr
32+
printer.println("parsed:\n" + unit.untpdTree.show)
3233
}
3334

3435
def enterSyms(implicit ctx: Context) = monitor("indexing") {

tests/pos/i851.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
interface I<T> {}
2+
3+
interface J<T> extends I<T> {
4+
default void $init$() {
5+
};
6+
}
7+
8+
class C<T> extends J<T> {}

0 commit comments

Comments
 (0)