从Scala 2.11.11升级到Scala 2.12.3后的Trait Subtractable问题

时间:2017-08-18 10:22:12

标签: scala playframework

我迁移了我的Scala Play!从Scala 2.11.11到Scala 2.12.3的应用程序

从那时起,我在编译应用程序时遇到以下错误:

type arguments [?,Equals] do not conform to trait Subtractable's type parameter bounds [A,+Repr <: scala.collection.generic.Subtractable[A,Repr]]
[error]       for (req <- request.req.getRequestList) {
[error]                               ^
[error] one error found

出于某种原因,Scala 2.12似乎有问题迭代Java Array。

getRequestList返回以下对象:Array [Req]。

有没有人遇到过这个问题?

以下是我遇到问题的代码部分:

  // Sorting the requests by Certificate Authority
  for (req <- request.req.getRequestList) {
    // Extracting the Key Hash from the request
    val keyHash = getKeyHash(req)
    // Extracting the Name Hash from the request
    val nameHash = getNameHash(req)
    // Retrieving the CA from the Key Hash or Name Hash
    val ca = keyHash.flatMap(getCertificateAuthorityFromKeyHash).map { ca =>
      Logger.debug(s"[${self.path.name}] - CA found based on Issuer Key Hash ('${keyHash.getOrElse("NA").toUpperCase}') -> '${ca.name}'")
      ca
    } orElse nameHash.flatMap(getCertificateAuthorityFromNameHash).map { ca =>
      Logger.debug(s"[${self.path.name}] - CA found based on Issuer Name Hash ('${nameHash.getOrElse("NA").toUpperCase}') -> '${ca.name}'")
      ca
    } getOrElse {
      Logger.debug(s"[${self.path.name}] - Unable to find CA based on Issuer Key Hash ('${keyHash.getOrElse("NA").toUpperCase}') and Name Hash ('${nameHash.getOrElse("NA").toUpperCase}'. Discarding request with Unauthorized status)")
      throw new UnknownCertificateAuthorityException("CertificateID does not reference a registered Certificate Authority")
    }
    if (reqsByCA.contains(ca.id.get)) {
      reqsByCA(ca.id.get) += req
    } else {
      reqsByCA += (ca.id.get -> ArrayBuffer(req))
    }
  }

request.re.getRequestList返回一个org.bouncycastle.cert.ocsp.Req数组(Array [org.bouncycastle.cert.ocsp.Req])。

1 个答案:

答案 0 :(得分:0)

经过进一步调查后,问题出在这条线上:

reqsByCA(ca.id.get).append(req)

我将其替换为:

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

    if component == 0 {
        lbl1.text = pdata[0][row]
        lbl1.adjustsFontSizeToFitWidth = true
        img1.image = UIImage(named : pdata[0][row])
        price1.text = priceData[row]
        total1 = Int(priceData[row]) ?? 0

        }

 else if component == 1 {
        lbl2.text = pdata[1][row]
        lbl2.adjustsFontSizeToFitWidth = true
        img2.image = UIImage(named : imgdata[row])
        price2.text = PriceData2[row]
        total2 = Int(PriceData2[row]) ?? 0

    }

   TotalPrice.text = String(total1! + total2!)



}

对我而言,这完全相同......

现在它编译并运行。

如果有人能解释我的原因,我将不胜感激。

无论如何,我的问题已经解决了。