Skip to content

feature request: data flow based exhaustive checker #24746

@He-Pin

Description

@He-Pin
  def futureSource[T, M](futureSource: Future[Source[T, M]]): Source[T, Future[M]] = {
    val maybeValue = futureSource.value
    if (maybeValue eq None) {
      fromGraph(new FutureFlattenSource(futureSource))
    } else maybeValue match {
      case Some(scala.util.Success(null)) =>
        val exception = new NullPointerException("futureSource completed with null")
        Source.failed(exception).mapMaterializedValue(_ => Future.failed[M](exception))
      case Some(scala.util.Success(source)) => source.mapMaterializedValue(Future.successful)
      case Some(scala.util.Failure(ex))     => Source.failed[T](ex).mapMaterializedValue(_ => Future.failed[M](ex))
    }
  }

I have the current code, but the compiler say it will fails

[error] /Users/hepin/IdeaProjects/pekko/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:599:12: match may not be exhaustive.
[error] It would fail on the following input: None
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=other-match-analysis, site=org.apache.pekko.stream.scaladsl.Source.futureSource
[error]     } else maybeValue match {
[error]            ^
[error] two errors found
[error] (stream / Compile / compileIncremental) Compilation failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions