Skip to content

Possibly incorrect check for lower bounds #15678

Closed
@WojciechMazur

Description

@WojciechMazur

Community build regression for https://github.com/johnhungerford/generic-schema (maintainer @johnhungerford)
Based on Open Community Build #2564
Part of #15647 regressions tracker

Compiler version

Works in 3.1.2
Fails in 3.1.3
Fails in 3.2.1-RC1-bin-20220712-7e20b81-NIGHTLY

Probably further minimization might be helpfull

Minimized code

type TypeName = String & Singleton

trait Subtype[T]:
  type Name <: TypeName
object Subtype:
  type Aux[T, N <: TypeName] = Subtype[T] { type Name = N }

trait SubtypeReplacer[N <: TypeName, NewSubT, R <: Tuple]:
  type Out
  def replace(subtypes: R, withSubtype: NewSubT): Out

object SubtypeReplacer {
  given found[N <: TypeName, NewSubT, OldT, Tail <: Tuple]
      : SubtypeReplacer[N, NewSubT, Subtype.Aux[OldT, N] *: Tail] with {
    type Out = NewSubT *: Tail

    override def replace(
        subtypes: Subtype.Aux[OldT, N] *: Tail,
        withSubtype: NewSubT
    ): Out = withSubtype *: subtypes.tail
  }

  def replace[N <: TypeName, NewSubT, R <: Tuple](
      typeName: N,
      from: R,
      withSubtype: NewSubT
  )(using
      strp: SubtypeReplacer[N, NewSubT, R]
  ): strp.Out = strp.replace(from, withSubtype)
}

Output

[error] ./test.scala:20:26: Type argument Tail does not conform to lower bound Tuple.Tail[Subtype.Aux[OldT, N] *: Tail]
[error]     ): Out = withSubtype *: subtypes.tail
[error]    

Expectation

Should compile

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions