Skip to content

Commit f0c2a90

Browse files
committed
Fix #879
Don't insert a constructor call when typechecking Java classes.
1 parent edfb6e7 commit f0c2a90

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ object JavaParsers {
145145
// ------------- general parsing ---------------------------
146146

147147
/** skip parent or brace enclosed sequence of things */
148-
def skipAhead(): Unit = {
148+
def skipAhead(openBraces: Int = 0): Unit = {
149149
var nparens = 0
150-
var nbraces = 0
150+
var nbraces = openBraces
151151
do {
152152
in.token match {
153153
case LPAREN =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
10271027
*/
10281028
def ensureConstrCall(cls: ClassSymbol, parents: List[Tree])(implicit ctx: Context): List[Tree] = {
10291029
val firstParent :: otherParents = parents
1030-
if (firstParent.isType && !(cls is Trait))
1030+
if (firstParent.isType && !(cls is Trait) && !cls.is(JavaDefined))
10311031
typed(untpd.New(untpd.TypedSplice(firstParent), Nil)) :: otherParents
10321032
else parents
10331033
}

tests/pos/i879.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Foo {
2+
Foo(int i) {
3+
}
4+
}
5+
6+
7+
class Bar extends Foo {
8+
Bar() {
9+
super(10);
10+
}
11+
}

0 commit comments

Comments
 (0)