scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Regression in legality of SAM methods

Open WojciechMazur opened this issue 3 years ago • 1 comments

Regression found in the Open CB #8414 for mjakubowski84/parquet4s

Compiler version

Fails with 3.2.1-RC2 Works with 3.2.1-RC1

Bisect points to 57f53d0725c859bffcadc8919524b9b0d43805ba Might be related to https://github.com/lampepfl/dotty/issues/16049 and it's fix https://github.com/lampepfl/dotty/pull/16070

Minimized code

trait Column[V]
trait ColumnPath

trait ColumnFactory[V, C <: Column[V]]:
  def apply(columnPath: ColumnPath): C

object ColumnFactory:
  private def apply[V, C <: Column[V]](f: String => C): ColumnFactory[V, C] =
    columnPath => f(columnPath.toString())

Output

Compiling project (Scala 3.2.1-RC2, JVM)
[error] ./test.scala:9:43: ColumnFactory[V, C] is not a legal SAM type
[error] since it has a member C with possibly conflicting bounds C <: ... <: Column[V] & C
[error]     columnPath => f(columnPath.toString())
[error]                                           ^

Expectation

Should compile

WojciechMazur avatar Sep 20 '22 08:09 WojciechMazur

I verified that #16070 fixes this as well.

odersky avatar Sep 20 '22 14:09 odersky