-
Notifications
You must be signed in to change notification settings - Fork 21
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
warn on implicit def without explicit result type #5265
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5265?orig=1 |
@adriaanm said: |
@retronym said: Instead, I think the problem here is that The presentation compiler has a more robust namer to account for the sort of symptom, as caused by cancellation. I've moved that in to the regular namer in this WIP branch. https://github.com/retronym/scala/tree/ticket/5265 That said, I definetely agree we should also have a warning / migration for unannotated implicits. |
@retronym said: // t4716.scala
trait Bug2[ +A] extends TraversableOnce[A] {
def ++[B >: A](that: TraversableOnce[B]) = {
lazy val it = that.toIterator
it
}
} I'm going to park this ticket again. |
This'd be a great project for somebody. It has increased significance lately given that Scala 3 requires the explicit result type:
So I would say that Is there a volunteer who would like to tackle it? |
To whoever would like to take this on, note that the warning should not apply to local definitions, i.e., those for which |
Possible typo for Som, homebody. Or is that a portmanteau? |
Possible noise reduction if it accepted
The first form, in particular, adds information. The second could be transposed. The current exemption is for override in Scala 3/-Xsource:3. |
… `Implicit definition should have explicit type` ### What changes were proposed in this pull request? This PR aims to fix `Implicit definition should have explicit type` in Scala 2.13. This pr includes: 1. Declaration types for global variables of implicit 2. Add scala.annotation.warn ### Why are the changes needed? - For implicit global variables without explicit type declaration, will get warnning : warning: Implicit definition should have explicit type (inferred String) [quickfixable] - No modifications are required for local variables. Additionally, to handle cases involving reflection-related types like ClassTag in implicit variables, the [scala.annotation.warn](https://github.com/scala.annotation.warn) annotation is used to suppress the warning. Furthermore, warnings generated in Spark will be treated as errors: [error] ... Implicit definition should have explicit type (inferred org.json4s.DefaultFormats.type) [quickfixable] ... [error] implicit val formats = org.json4s.DefaultFormats Jira link: SPARK-45314: https://issues.apache.org/jira/browse/SPARK-45629 Related issue link about `implicit` : scala/bug#5265 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Most of the testing is completed through CI, and the example module is locally compiled and tested in IDEA Additionally, there are some writing changes that are verified through demo code ### Was this patch authored or co-authored using generative AI tooling? no Closes #43526 from laglangyue/SPARK-45629. Lead-authored-by: tangjiafu <jiafu.tang@qq.com> Co-authored-by: tangjiafu <tangjiafu@corp.netease.com> Signed-off-by: yangjie01 <yangjie01@baidu.com>
… `Implicit definition should have explicit type` ### What changes were proposed in this pull request? This PR aims to fix `Implicit definition should have explicit type` in Scala 2.13. This pr includes: 1. Declaration types for global variables of implicit 2. Add scala.annotation.warn ### Why are the changes needed? - For implicit global variables without explicit type declaration, will get warnning : warning: Implicit definition should have explicit type (inferred String) [quickfixable] - No modifications are required for local variables. Additionally, to handle cases involving reflection-related types like ClassTag in implicit variables, the [scala.annotation.warn](https://github.com/scala.annotation.warn) annotation is used to suppress the warning. Furthermore, warnings generated in Spark will be treated as errors: [error] ... Implicit definition should have explicit type (inferred org.json4s.DefaultFormats.type) [quickfixable] ... [error] implicit val formats = org.json4s.DefaultFormats Jira link: SPARK-45314: https://issues.apache.org/jira/browse/SPARK-45629 Related issue link about `implicit` : scala/bug#5265 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Most of the testing is completed through CI, and the example module is locally compiled and tested in IDEA Additionally, there are some writing changes that are verified through demo code ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#43526 from laglangyue/SPARK-45629. Lead-authored-by: tangjiafu <jiafu.tang@qq.com> Co-authored-by: tangjiafu <tangjiafu@corp.netease.com> Signed-off-by: yangjie01 <yangjie01@baidu.com>
… `Implicit definition should have explicit type` ### What changes were proposed in this pull request? This PR aims to fix `Implicit definition should have explicit type` in Scala 2.13. This pr includes: 1. Declaration types for global variables of implicit 2. Add scala.annotation.warn ### Why are the changes needed? - For implicit global variables without explicit type declaration, will get warnning : warning: Implicit definition should have explicit type (inferred String) [quickfixable] - No modifications are required for local variables. Additionally, to handle cases involving reflection-related types like ClassTag in implicit variables, the [scala.annotation.warn](https://github.com/scala.annotation.warn) annotation is used to suppress the warning. Furthermore, warnings generated in Spark will be treated as errors: [error] ... Implicit definition should have explicit type (inferred org.json4s.DefaultFormats.type) [quickfixable] ... [error] implicit val formats = org.json4s.DefaultFormats Jira link: SPARK-45314: https://issues.apache.org/jira/browse/SPARK-45629 Related issue link about `implicit` : scala/bug#5265 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Most of the testing is completed through CI, and the example module is locally compiled and tested in IDEA Additionally, there are some writing changes that are verified through demo code ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#43526 from laglangyue/SPARK-45629. Lead-authored-by: tangjiafu <jiafu.tang@qq.com> Co-authored-by: tangjiafu <tangjiafu@corp.netease.com> Signed-off-by: yangjie01 <yangjie01@baidu.com> # Conflicts: # connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala # core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala # pom.xml # project/SparkBuild.scala # sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala # sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/OperatorStateMetadata.scala
set scala dependencies for 2.13 fix delta-core to delta-spark fix for scala 2.13 [SPARK-45629][CORE][SQL][CONNECT][ML][STREAMING][BUILD][EXAMPLES] Fix `Implicit definition should have explicit type` ### What changes were proposed in this pull request? This PR aims to fix `Implicit definition should have explicit type` in Scala 2.13. This pr includes: 1. Declaration types for global variables of implicit 2. Add scala.annotation.warn ### Why are the changes needed? - For implicit global variables without explicit type declaration, will get warnning : warning: Implicit definition should have explicit type (inferred String) [quickfixable] - No modifications are required for local variables. Additionally, to handle cases involving reflection-related types like ClassTag in implicit variables, the [scala.annotation.warn](https://github.com/scala.annotation.warn) annotation is used to suppress the warning. Furthermore, warnings generated in Spark will be treated as errors: [error] ... Implicit definition should have explicit type (inferred org.json4s.DefaultFormats.type) [quickfixable] ... [error] implicit val formats = org.json4s.DefaultFormats Jira link: SPARK-45314: https://issues.apache.org/jira/browse/SPARK-45629 Related issue link about `implicit` : scala/bug#5265 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Most of the testing is completed through CI, and the example module is locally compiled and tested in IDEA Additionally, there are some writing changes that are verified through demo code ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#43526 from laglangyue/SPARK-45629. Lead-authored-by: tangjiafu <jiafu.tang@qq.com> Co-authored-by: tangjiafu <tangjiafu@corp.netease.com> Signed-off-by: yangjie01 <yangjie01@baidu.com> # Conflicts: # connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala # core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala # pom.xml # project/SparkBuild.scala # sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala # sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/OperatorStateMetadata.scala Revert "[SPARK-45629][CORE][SQL][CONNECT][ML][STREAMING][BUILD][EXAMPLES] Fix `Implicit definition should have explicit type`" This reverts commit bc67612. Fix Implicit definition should have explicit type fix install error add args for scala 2.13 fix args update pom java version update pom jvm target version fix implicit types rollback scala 2.13.8 rollback fmt blank space fix
set scala dependencies for 2.13 fix delta-core to delta-spark fix for scala 2.13 [SPARK-45629][CORE][SQL][CONNECT][ML][STREAMING][BUILD][EXAMPLES] Fix `Implicit definition should have explicit type` ### What changes were proposed in this pull request? This PR aims to fix `Implicit definition should have explicit type` in Scala 2.13. This pr includes: 1. Declaration types for global variables of implicit 2. Add scala.annotation.warn ### Why are the changes needed? - For implicit global variables without explicit type declaration, will get warnning : warning: Implicit definition should have explicit type (inferred String) [quickfixable] - No modifications are required for local variables. Additionally, to handle cases involving reflection-related types like ClassTag in implicit variables, the [scala.annotation.warn](https://github.com/scala.annotation.warn) annotation is used to suppress the warning. Furthermore, warnings generated in Spark will be treated as errors: [error] ... Implicit definition should have explicit type (inferred org.json4s.DefaultFormats.type) [quickfixable] ... [error] implicit val formats = org.json4s.DefaultFormats Jira link: SPARK-45314: https://issues.apache.org/jira/browse/SPARK-45629 Related issue link about `implicit` : scala/bug#5265 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Most of the testing is completed through CI, and the example module is locally compiled and tested in IDEA Additionally, there are some writing changes that are verified through demo code ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#43526 from laglangyue/SPARK-45629. Lead-authored-by: tangjiafu <jiafu.tang@qq.com> Co-authored-by: tangjiafu <tangjiafu@corp.netease.com> Signed-off-by: yangjie01 <yangjie01@baidu.com> # Conflicts: # connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala # core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala # pom.xml # project/SparkBuild.scala # sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala # sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/OperatorStateMetadata.scala Revert "[SPARK-45629][CORE][SQL][CONNECT][ML][STREAMING][BUILD][EXAMPLES] Fix `Implicit definition should have explicit type`" This reverts commit bc67612. Fix Implicit definition should have explicit type fix install error add args for scala 2.13 fix args update pom java version update pom jvm target version fix implicit types rollback scala 2.13.8 rollback fmt blank space fix fix import fmt
set scala dependencies for 2.13 fix delta-core to delta-spark fix for scala 2.13 [SPARK-45629][CORE][SQL][CONNECT][ML][STREAMING][BUILD][EXAMPLES] Fix `Implicit definition should have explicit type` ### What changes were proposed in this pull request? This PR aims to fix `Implicit definition should have explicit type` in Scala 2.13. This pr includes: 1. Declaration types for global variables of implicit 2. Add scala.annotation.warn ### Why are the changes needed? - For implicit global variables without explicit type declaration, will get warnning : warning: Implicit definition should have explicit type (inferred String) [quickfixable] - No modifications are required for local variables. Additionally, to handle cases involving reflection-related types like ClassTag in implicit variables, the [scala.annotation.warn](https://github.com/scala.annotation.warn) annotation is used to suppress the warning. Furthermore, warnings generated in Spark will be treated as errors: [error] ... Implicit definition should have explicit type (inferred org.json4s.DefaultFormats.type) [quickfixable] ... [error] implicit val formats = org.json4s.DefaultFormats Jira link: SPARK-45314: https://issues.apache.org/jira/browse/SPARK-45629 Related issue link about `implicit` : scala/bug#5265 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Most of the testing is completed through CI, and the example module is locally compiled and tested in IDEA Additionally, there are some writing changes that are verified through demo code ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#43526 from laglangyue/SPARK-45629. Lead-authored-by: tangjiafu <jiafu.tang@qq.com> Co-authored-by: tangjiafu <tangjiafu@corp.netease.com> Signed-off-by: yangjie01 <yangjie01@baidu.com> # Conflicts: # connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala # core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala # pom.xml # project/SparkBuild.scala # sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala # sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/OperatorStateMetadata.scala Revert "[SPARK-45629][CORE][SQL][CONNECT][ML][STREAMING][BUILD][EXAMPLES] Fix `Implicit definition should have explicit type`" This reverts commit bc67612. Fix Implicit definition should have explicit type fix install error add args for scala 2.13 fix args update pom java version update pom jvm target version fix implicit types rollback scala 2.13.8 rollback fmt blank space fix fix import fmt fmt not fail on violation
The following code snipet : https://gist.github.com/1427587
does not compile.
The text was updated successfully, but these errors were encountered: