Skip to content
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

Rework compile time error message for scala 3 #145

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import de.tobiasroeser.mill.vcs.version.VcsVersion

val scala213 = "2.13.10"
val scala212 = "2.12.17"
val scala3 = "3.2.2"
val scala3 = "3.3.4"
val scalaJS = "1.13.0"
val communityBuildDottyVersion = sys.props.get("dottyVersion").toList

Expand Down
4 changes: 3 additions & 1 deletion cask/src-3/cask/router/Macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ object Macros {
case iss: ImplicitSearchSuccess =>
iss.tree.asExpr
case isf: ImplicitSearchFailure =>
report.error(s"can't convert ${rtp.typeSymbol.fullName} to a response", method.pos.get)
def prettyPos(pos: Position) =
s"${pos.sourceFile}:${pos.startLine + 1}:${pos.startColumn + 1}"
report.error(s"error in route definition `def ${method.name}` (at ${prettyPos(method.pos.get)}): the method's return type ${rtp.show} cannot be converted to the expected response type ${innerReturnedTpt.show}", method.pos.get)
'{???}
}

Expand Down
19 changes: 19 additions & 0 deletions cask/test/src-3/test/cask/FailureTests3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package test.cask

import cask.model.Request
import utest._

object FailureTests3 extends TestSuite {
val tests = Tests{
"returnType" - {
utest.compileError("""
object Routes extends cask.MainRoutes{
@cask.get("/foo")
def hello(world: String) = (1, 1)
initialize()
}
""").msg ==>
"error in route definition `def hello` (at tasty-reflect:4:15): the method's return type scala.Tuple2[scala.Int, scala.Int] cannot be converted to the expected response type cask.model.Response[cask.model.Response.Data]"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the position "tasty-reflect:4:15" is synthetic in this test. I manually verified that the error position is correct on an actual cask project.

}
}
}
Loading