Scala Programming Language
  1. Scala Programming Language
  2. SI-7756

RefChecks partially disabled in case bodies under virtpatmat

    Details

      Description

      object Test {
        def test: Unit = {
          trait TA[X <: CharSequence]
          0 match {
            case _ =>
              // the bounds violation isn't reported. RefChecks seems to be too broadly disabled under virtpatmat: see 65340ed4ad2e
              locally(null: TA[Object])
              ()
          }
        }
      }
      
              // skip refchecks in patterns....
              result = result match {
                case CaseDef(pat, guard, body) =>
                  inPattern = true
                  val pat1 = transform(pat)
                  inPattern = false
                  treeCopy.CaseDef(tree, pat1, transform(guard), transform(body))
                case LabelDef(_, _, _) if treeInfo.hasSynthCaseSymbol(result) =>
                  val old = inPattern
                  inPattern = true
                  val res = deriveLabelDef(result)(transform)
                  inPattern = old
                  res
                case ValDef(_, _, _, _) if treeInfo.hasSynthCaseSymbol(result) =>
                  deriveValDef(result)(transform)
                case _ =>
                  super.transform(result)
              }
      

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -

          Discovered during investigations of SI-7716.

          Show
          Jason Zaugg added a comment - Discovered during investigations of SI-7716 .
          Hide
          Jason Zaugg added a comment -

          Similarly:

          scala> 1 == ""
          <console>:8: warning: comparing values of types Int and String using `==' will always yield false
                        1 == ""
                          ^
          res0: Boolean = false
          
          scala> 0 match { case _ => 1 == "" }
          res1: Boolean = false
          

          Finer grains are called for.

          Show
          Jason Zaugg added a comment - Similarly: scala> 1 == "" <console>:8: warning: comparing values of types Int and String using `==' will always yield false 1 == "" ^ res0: Boolean = false scala> 0 match { case _ => 1 == "" } res1: Boolean = false Finer grains are called for.
          Show
          Jason Zaugg added a comment - https://github.com/retronym/scala/tree/ticket/7756 https://scala-webapps.epfl.ch/jenkins/job/scala-checkin-manual/993/console
          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/2840
          Show
          Adriaan Moors added a comment - https://github.com/scala/scala/pull/2840

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Jason Zaugg
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development