-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Basic usages triggers compiler warnings when using -Xlint #320
Comments
I'm not really sure that it's a library bug. |
I do not understand the relevancy of the links the first one is just saying that the flag is good for catching potentially problematic code. The second link seems to be about some other bug that is fixed later versions of scalac so it seems likely we are not hitting that bug? So I had a look at the code to see what triggers it and found this: scala-jsonschema/macros/src/main/scala/com/github/andyglow/jsonschema/UImplicits.scala Lines 17 to 48 in 6ebc7a2
Lets take for example this code: package test
import json._
object TestNullAtRuntime {
case class UserId(value: String) extends AnyVal
implicit val userIdSchema: json.Schema[ // Some nice comment
UserId
] = Json.schema[UserId].toDefinition("userId")
def main(args: Array[String]): Unit = {
println(userIdSchema)
}
}
Trying to run this code will crash with:
so it failed to detect the self implicit and the compiler warning is not a false positive and actually found the bug. Code like this package test
import json._
object TestDoesNotCompile {
case class UserId(value: String) extends AnyVal
def main(args: Array[String]): Unit = {
implicit val userIdSchema: json.Schema[UserId] = Json.schema[UserId].toDefinition("userId")
println(userIdSchema)
}
} will fail compilation with
But my favorite one is code like this: package test
import json._
object TestCLRF {
case class UserId(value: String) extends AnyVal
implicit val userIdSchema: json.Schema[UserId] =
Json.schema[UserId].toDefinition("userId")
def main(args: Array[String]): Unit = {
println(userIdSchema)
}
} which compiles and does the correct thing if the file as LF line endings but change it to have CRLF and it fails at runtime with
|
Describe the bug
Usage of the library triggers compiler warnings when setting
-Xlint
.To Reproduce
Compiling code like (based on readme examples)
with
-Xlint
and `-Wconf:any:warning-verbose" results in warnings likeExpected behavior
Basic usage of library should compile without warnings.
Actual results
Compiler warnings.
Versions:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: