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

compile error #1018

Closed
zhaodaye2022 opened this issue Apr 26, 2024 · 5 comments
Closed

compile error #1018

zhaodaye2022 opened this issue Apr 26, 2024 · 5 comments

Comments

@zhaodaye2022
Copy link

zhaodaye2022 commented Apr 26, 2024

Are you looking for help?

This is an issue tracker, used to manage and track the development of Play JSON. It is not a support system and so it is not a place to ask questions or get help. If you're not sure if you have found a bug, the best place to start is with either the Play Discussion Forum or Stack Overflow.

If you want to discuss a feature request, the same tools are available.

Play JSON Version (2.5.x / etc)

3.0.2

API (Scala / Java / Neither / Both)

Scala

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

macos

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

jdk11

Library Dependencies

If this is an issue that involves integration with another system, include the exact version and OS of the other system, including any intermediate drivers or APIs i.e. if you connect to a PostgreSQL database, include both the version / OS of PostgreSQL and the JDBC driver version used to connect to the database.

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

[info] compiling 58 Scala sources and 1 Java source to /Volumes/data/dev/tas/basics-model/target/scala-3.3.3/classes ...
[error] -- Error: /Volumes/data/dev/tas/basics-model/src/main/scala/com/tallsafe/model/common/HttpResponse.scala:40:15 
[error] 40 |    Json.format[HttpResponse[T]]
[error]    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Actual Behavior

Please provide a description of what actually happens, working from the same starting point.

Be descriptive: "it doesn't work" does not describe what the behavior actually is -- instead, say "the page renders a 500 error code with no body content." Copy and paste logs, and include any URLs. Turn on internal Play JSON logging with <logger name="play" value="TRACE"/> if there is no log output.

Reproducible Test Case

Please provide a PR with a failing test.

If the issue is more complex or requires configuration, please provide a link to a project on Github that reproduces the issue.

@mkurz
Copy link
Member

mkurz commented Apr 29, 2024

[info] compiling 58 Scala sources and 1 Java source to /Volumes/data/dev/tas/basics-model/target/scala-3.3.3/classes ...
[error] -- Error: /Volumes/data/dev/tas/basics-model/src/main/scala/com/tallsafe/model/common/HttpResponse.scala:40:15 
[error] 40 |    Json.format[HttpResponse[T]]
[error]    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sorry, but this is not much information. What is the actual error message? We need some more context and information.

@zhaodaye2022
Copy link
Author

case class HttpResponse[T: ClassTag](
Status: Boolean = true,
StatusCode: Int = 200,
var RequestURL: Option[String] = None,
StatusString: Option[String] = None,
LocalTime: Option[String] = Some(LocalDateTime.now().toString),
Data: Option[T] = None,
Total: Option[Int] = None,
Alter: Option[Int] = None,
SearchToken:Option[String] =None
)

object HttpResponse {
implicit def httpResponseFormat[T: ClassTag](implicit fmt: Format[T]): OFormat[HttpResponse[T]] =
Json.format[HttpResponse[T]]
}

@zhaodaye2022
Copy link
Author

Instance not found: 'ProductOf[com.tallsafe.model.common.HttpResponse[T]]'

@zhaodaye2022
Copy link
Author

When the case class contains generic T, it will compile an error

@zhaodaye2022
Copy link
Author

remove: ClassTag is working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants