@@ -47,8 +47,13 @@ private[scalacoptions] trait ScalacOptions {
47
47
ScalacOption (" -encoding" , List (enc), _ => true )
48
48
49
49
/** Emit warning and location for usages of deprecated APIs.
50
+ *
51
+ * Deprecated in 2.13.0 and replaced by -Xlint:deprecation.
50
52
*/
51
- val deprecation = ScalacOption (" -deprecation" , _ => true )
53
+ val deprecation = ScalacOption (
54
+ " -deprecation" ,
55
+ version => version < V2_13_0 || version >= V3_0_0
56
+ )
52
57
53
58
/** Emit warning and location for usages of features that should be imported explicitly.
54
59
*/
@@ -241,6 +246,8 @@ private[scalacoptions] trait ScalacOptions {
241
246
)
242
247
243
248
/** Enable linted deprecations.
249
+ *
250
+ * Added in 2.13.0, backported to 2.12.13.
244
251
*/
245
252
val lintDeprecation =
246
253
lintOption(" deprecation" , version => version.isBetween(V2_12_13 , V3_0_0 ))
@@ -656,9 +663,22 @@ private[scalacoptions] trait ScalacOptions {
656
663
warnOption(" numeric-widen" , version => version.isBetween(V2_13_0 , V3_0_0 ))
657
664
658
665
/** Warn when non-Unit expression results are unused.
666
+ *
667
+ * Added in 2.13.0, ported to 3.3.0.
659
668
*/
660
669
val warnValueDiscard =
661
- warnOption(" value-discard" , version => version.isBetween(V2_13_0 , V3_0_0 ))
670
+ warnOption(
671
+ " value-discard" ,
672
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
673
+ )
674
+
675
+ /** Warn when an expression is ignored because it is followed by another expression.
676
+ */
677
+ val warnNonUnitStatement =
678
+ warnOption(
679
+ " nonunit-statement" ,
680
+ version => version.isBetween(V2_13_9 , V3_0_0 )
681
+ )
662
682
663
683
/** Fail the compilation if there are any warnings.
664
684
*/
@@ -674,46 +694,81 @@ private[scalacoptions] trait ScalacOptions {
674
694
ScalacOption (s " -Wunused: $name" , isSupported)
675
695
676
696
/** Warn if a @nowarn annotation did not suppress at least one warning.
697
+ *
698
+ * Added in 2.13.2, backported to 2.12.13.
677
699
*/
678
700
val warnUnusedNoWarn =
679
- warnUnusedOption(" nowarn" , version => version.isBetween(V2_13_0 , V3_0_0 ))
701
+ warnUnusedOption(
702
+ " nowarn" ,
703
+ version => version.isBetween(V2_12_13 , V2_13_0 ) || version.isBetween(V2_13_2 , V3_0_0 )
704
+ )
680
705
681
706
/** Warn if an implicit parameter is unused.
707
+ *
708
+ * Added in 2.13.0, ported to 3.3.0.
682
709
*/
683
710
val warnUnusedImplicits =
684
- warnUnusedOption(" implicits" , version => version.isBetween(V2_13_0 , V3_0_0 ))
711
+ warnUnusedOption(
712
+ " implicits" ,
713
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
714
+ )
685
715
686
716
/** Warn if an explicit parameter is unused.
717
+ *
718
+ * Added in 2.13.0, ported to 3.3.0.
687
719
*/
688
720
val warnUnusedExplicits =
689
- warnUnusedOption(" explicits" , version => version.isBetween(V2_13_0 , V3_0_0 ))
721
+ warnUnusedOption(
722
+ " explicits" ,
723
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
724
+ )
690
725
691
726
/** Warn if an import selector is not referenced.
727
+ *
728
+ * Added in 2.13.0, ported to 3.3.0.
692
729
*/
693
730
val warnUnusedImports =
694
- warnUnusedOption(" imports" , version => version.isBetween(V2_13_0 , V3_0_0 ))
731
+ warnUnusedOption(
732
+ " imports" ,
733
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
734
+ )
695
735
696
736
/** Warn if a local definition is unused.
737
+ *
738
+ * Added in 2.13.0, ported to 3.3.0.
697
739
*/
698
740
val warnUnusedLocals =
699
- warnUnusedOption(" locals" , version => version.isBetween(V2_13_0 , V3_0_0 ))
741
+ warnUnusedOption(
742
+ " locals" ,
743
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
744
+ )
700
745
701
746
/** Warn if either explicit or implicit parameters are unused.
702
747
*
703
748
* Equivalent to -Wunused:explicits,implicits.
749
+ *
750
+ * Added in 2.13.0, ported to 3.3.0.
704
751
*/
705
752
val warnUnusedParams =
706
- warnUnusedOption(" params" , version => version.isBetween(V2_13_0 , V3_0_0 ))
753
+ warnUnusedOption(
754
+ " params" ,
755
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
756
+ )
707
757
708
758
/** Warn if a variable bound in a pattern is unused.
709
759
*/
710
760
val warnUnusedPatVars =
711
761
warnUnusedOption(" patvars" , version => version.isBetween(V2_13_0 , V3_0_0 ))
712
762
713
763
/** Warn if a private member is unused.
764
+ *
765
+ * Added in 2.13.0, ported to 3.3.0.
714
766
*/
715
767
val warnUnusedPrivates =
716
- warnUnusedOption(" privates" , version => version.isBetween(V2_13_0 , V3_0_0 ))
768
+ warnUnusedOption(
769
+ " privates" ,
770
+ version => version.isBetween(V2_13_0 , V3_0_0 ) || version.isAtLeast(V3_3_0 )
771
+ )
717
772
718
773
/** Unused warning options (-Wunused:)
719
774
*/
@@ -734,7 +789,8 @@ private[scalacoptions] trait ScalacOptions {
734
789
warnDeadCode,
735
790
warnExtraImplicit,
736
791
warnNumericWiden,
737
- warnValueDiscard
792
+ warnValueDiscard,
793
+ warnNonUnitStatement
738
794
) ++ warnUnusedOptions
739
795
740
796
/** Options which fail the compilation if there are any warnings.
@@ -744,6 +800,39 @@ private[scalacoptions] trait ScalacOptions {
744
800
warnError
745
801
)
746
802
803
+ /** Verbose options (-V)
804
+ */
805
+ def verboseOption (name : String , isSupported : ScalaVersion => Boolean = _ => true ) =
806
+ ScalacOption (s " -V $name" , isSupported)
807
+
808
+ /** Print dependent missing implicits.
809
+ */
810
+ val verboseImplicits =
811
+ verboseOption(" implicits" , _.isBetween(V2_13_0 , V3_0_0 ))
812
+
813
+ /** Print found/required error messages as colored diffs.
814
+ */
815
+ val verboseTypeDiffs =
816
+ verboseOption(" type-diffs" , _.isBetween(V2_13_6 , V3_0_0 ))
817
+
818
+ /** Explain type errors in more detail.
819
+ */
820
+ val explainTypes =
821
+ ScalacOption (" -explaintypes" , _ < V3_0_0 )
822
+
823
+ /** Explain errors in more detail.
824
+ */
825
+ val explain = ScalacOption (" -explain" , _ >= V3_0_0 )
826
+
827
+ /** Verbose options (-V)
828
+ */
829
+ val verboseOptions : Set [ScalacOption ] = ListSet (
830
+ verboseImplicits,
831
+ verboseTypeDiffs,
832
+ explainTypes,
833
+ explain
834
+ )
835
+
747
836
/** The default set of Scala compiler options defined by sbt-tpolecat.
748
837
*/
749
838
val default : Set [ScalacOption ] = ListSet (
0 commit comments