-
Notifications
You must be signed in to change notification settings - Fork 1.1k
unhelpful error message when overloading apply without return type #1731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have a tentative fix for this, should have something up to review in the next couple of days. |
Just trying to wrap this up by adding a new test like this: checkMessagesAfter("frontend") {
"""
|case class Foo[T](x: T)
|object Foo { def apply[T]() = Foo(null.asInstanceOf[T]) }
""".stripMargin
}.expect { (ictx, messages) =>
implicit val ctx: Context = ictx
assertMessageCount(1, messages)
val OverloadedOrRecursiveMethodNeedsResultType(treeName2) :: Nil = messages
assertEquals("Foo", treeName2)
} This results in:
I assume I'm doing something incorrect with which phase I'm picking, but having tried a few with no change of results (other than the phase apparently not being supported), wanted to check here for any insight. |
No clue, /cc @felixmulder who wrote |
…turn type idenitified possible solution issue seems fixed - fixed existing tests; new test isn't working right disabling new test for now
Looking into it for @bbarker's PR, I think the assertion is run using the wrong context. |
Nope, it works fine to run the commented out |
…hod without return type
The original example in #1731 now shows: overloaded or recursive method Foo needs return type But this is incorrect, |
…od without re… (scala#2823)" This reverts commit 91d3ec1.
The PR was reverted |
dotty
:The solution is to write
def apply[T](): Foo[T]
but good luck figuring that out from our error message, contrast withscalac
:The text was updated successfully, but these errors were encountered: