scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

type alias with bound may cause subtyping judgement to break #12872

Closed tribbloid closed 4 months ago

tribbloid commented 9 months ago

Reproduction steps

Scala version: 2.13.12

object Spike {

  trait Conj

  trait Topology { type Conj_/\ <: Conj }

  abstract class GraphBuilder[T <: Topology](val topology: T) {

    type Conj_/\ = topology.Conj_/\
  }

  type Of[C <: Conj] = GraphBuilder[_] { type Conj_/\ <: C }

  def sanity[C <: Conj]: Unit = { // sanity

    val example: Of[C] = ???

    implicitly[example.Conj_/\ <:< C]

    val a: example.Conj_/\ = ???
    val b: C = a
  }
}

Problem

The following errors are invalid:

[Error] /home/peng/git-proto/scalaspike/common/src/test/scala/com/tribbloids/spike/scalaspike/Spike.scala:20:15: implicit error; !I e: example.topology.Conj/\ <:< C Cannot prove that example.Conj_/\ <:< C.

[Error] /home/peng/git-proto/scalaspike/common/src/test/scala/com/tribbloids/spike/scalaspike/Spike.scala:23:16: type mismatch; found : a.type (with underlying type example.Conj/) required: C two errors found

SethTisue commented 4 months ago

see my remarks on https://github.com/scala/bug/issues/12952 about filing quality bug reports