首页 > 解决方案 > 无法解析重载的方法映射 Scala 2.10.12/Intellij 2019.2.2

问题描述

def saveOffsetRanges(offsetRanges: ListBuffer[OffsetRange], consumer: String): Unit = {

println(s"offsets to redis${offsetRanges}")

val client = JedisUtil.getClient()

val map = offsetRanges
  .groupBy(_.topic)
    .map{ // errors found : cannot resolve overloaded method 
      case (topic , offsets) =>
        val partitionToOffset = offsets.map(info => {
          info.partition.toString() -> info.untilOffset.toString
        })

        Serialization.write(partitionToOffset)
    }

client.close()


}

发现想法错误:无法解析重载方法'map',但'map'在scala中很常见。我确信代码是正确的。

在此处输入图像描述

然后我尝试使缓存无效并重新启动(IDEA -> File -> Invalide Caches/Restart)。问题仍然存在,其他“地图”也无法解决,在我操作之前,其他“地图”没问题。

  def getOffsets(consumer: String) = {

val client = JedisUtil.getClient()

client.hgetAll(s"offset_$consumer")
  .asScala
  .map{// errors found : cannot resolve overloaded method 
    case (partition,offset) =>
      val tp = new TopicPartition(partition.toInt)
      val o = offset.toLong
      tp->o
  }
 }

它真的是连线的,代码可以工作,但错误会影响编码(想法不要自动提示方法和类型)

标签: scalaintellij-idea

解决方案


推荐阅读