Repository: scalacenter/tasty-query (scala)

Issue:
Computing type of `new java.lang.Enum[Foo]()` throws `NonMethodReferenceException`
```scala
enum Foo extends java.lang.Enum[Foo]:
  case Bar
```

Somewhere inside the tree of `Foo` there is an `Apply` tree: `new java.lang.Enum[Foo]()`. If I compute the type of this tree it throws `NonMethodReferenceException` because the type of the `fun` is not a method type.

Pull request description:

Patch:
diff --git a/tasty-query/shared/src/main/scala/tastyquery/Definitions.scala b/tasty-query/shared/src/main/scala/tastyquery/Definitions.scala
index 17cec2e6..f8af43a5 100644
--- a/tasty-query/shared/src/main/scala/tastyquery/Definitions.scala
+++ b/tasty-query/shared/src/main/scala/tastyquery/Definitions.scala
@@ -270,7 +270,8 @@ final class Definitions private[tastyquery] (ctx: Context, rootPackage: PackageS
   lazy val String_+ : TermSymbol = StringClass.findNonOverloadedDecl(nme.m_+)
 
   private[tastyquery] def createEnumMagicMethods(cls: ClassSymbol): Unit =
-    createSpecialMethod(cls, nme.Constructor, PolyType(List(typeName("E")), List(NothingAnyBounds), UnitType))
+    val ctorTpe = PolyType(List(typeName("E")), List(NothingAnyBounds), MethodType(Nil, Nil, UnitType))
+    createSpecialMethod(cls, nme.Constructor, ctorTpe)
   end createEnumMagicMethods
 
   /** Creates the members that are patched from stdLibPatches on Predef.


Test patch:
diff --git a/tasty-query/shared/src/test/scala/tastyquery/TypeSuite.scala b/tasty-query/shared/src/test/scala/tastyquery/TypeSuite.scala
index d1a0ec3d..20ab2f25 100644
--- a/tasty-query/shared/src/test/scala/tastyquery/TypeSuite.scala
+++ b/tasty-query/shared/src/test/scala/tastyquery/TypeSuite.scala
@@ -2395,6 +2395,17 @@ class TypeSuite extends UnrestrictedUnpicklingSuite {
     assert(clue(app.tpe).isRef(anonClassSym))
   }
 
+  testWithContext("java-enum") {
+    val JavaLangEnumClass = ctx.findTopLevelClass("java.lang.Enum")
+    val JavaEnumClass = ctx.findTopLevelClass("simple_trees.JavaEnum")
+
+    val tree = JavaEnumClass.tree.get
+
+    findTree(tree.rhs.parents.head) { case apply: Apply =>
+      assert(clue(apply.tpe).isApplied(_.isRef(JavaLangEnumClass), List(_.isRef(JavaEnumClass))))
+    }
+  }
+
   testWithContext("toplevel-module-class-with-opaque-type-alias-companion-signature-name") {
     val TopLevelOpaqueTypeAliasModule =
       ctx.findStaticTerm("crosspackagetasty.TopLevelOpaqueTypeAlias$package.TopLevelOpaqueTypeAlias")
diff --git a/test-sources/src/main/scala/simple_trees/JavaEnum.scala b/test-sources/src/main/scala/simple_trees/JavaEnum.scala
new file mode 100644
index 00000000..509efcb0
--- /dev/null
+++ b/test-sources/src/main/scala/simple_trees/JavaEnum.scala
@@ -0,0 +1,5 @@
+package simple_trees
+
+enum JavaEnum extends java.lang.Enum[JavaEnum]():
+  case Foo, Bar
+end JavaEnum