diff --git a/tasty-query/shared/src/main/scala/tastyquery/reader/classfiles/ClassfileParser.scala b/tasty-query/shared/src/main/scala/tastyquery/reader/classfiles/ClassfileParser.scala index 0967dae4..6260ef87 100644 --- a/tasty-query/shared/src/main/scala/tastyquery/reader/classfiles/ClassfileParser.scala +++ b/tasty-query/shared/src/main/scala/tastyquery/reader/classfiles/ClassfileParser.scala @@ -329,6 +329,18 @@ private[reader] object ClassfileParser { else if cls.isString then rctx.createStringMagicMethods(cls) else if cls.isJavaEnum then rctx.createEnumMagicMethods(cls) + // Synthesize a constructor for interfaces + if cls.isTrait then + val ctor = TermSymbol + .create(nme.Constructor, cls) + .withDeclaredType(cls.makePolyConstructorType(MethodType(Nil, Nil, rctx.UnitType))) + .withFlags(Method | JavaDefined, None) + .setAnnotations(Nil) + .autoFillParamSymss() + ctor.paramSymss.foreach(_.merge.foreach(_.setAnnotations(Nil))) + allRegisteredSymbols += ctor + end if + loadMembers() val annotations = readAnnotations(cls, attributes) diff --git a/test-sources/src/main/scala/simple_trees/ClassExtendsJavaInterface.scala b/test-sources/src/main/scala/simple_trees/ClassExtendsJavaInterface.scala new file mode 100644 index 00000000..68c475fe --- /dev/null +++ b/test-sources/src/main/scala/simple_trees/ClassExtendsJavaInterface.scala @@ -0,0 +1,3 @@ +package simple_trees + +class ClassExtendsJavaInterface extends javadefined.JavaInterface1() diff --git a/test-sources/src/main/scala/simple_trees/ClassExtendsPolyJavaInterface.scala b/test-sources/src/main/scala/simple_trees/ClassExtendsPolyJavaInterface.scala new file mode 100644 index 00000000..e9c2ca4a --- /dev/null +++ b/test-sources/src/main/scala/simple_trees/ClassExtendsPolyJavaInterface.scala @@ -0,0 +1,5 @@ +package simple_trees + +class ClassExtendsPolyJavaInterface extends java.util.function.Predicate[String](): + def test(t: String): Boolean = t.isEmpty() +end ClassExtendsPolyJavaInterface