Skip to content

Higher-kinded implicit conversion with type aliasing has type mismatch error #10372

@soronpo

Description

@soronpo

Checkout DoesNotCompile vs Compiles1 and Compile2.
The higherKinds is somehow related since the if Func has no arguments, the code also compiles.
This code compiles in Dotty.
Possibly related bug: #10197
Scalac run in scastie: https://scastie.scala-lang.org/0nFlyoRDSRiOqdp2XsGbJQ
Dotty run in scastie: https://scastie.scala-lang.org/soronpo/7qttyh67RsmTUoQ8mHlBkw

import scala.language.higherKinds
import scala.language.implicitConversions
class Expected[T, Func[_]]
implicit def conv[T, Func[_]](i : Int) : Expected[T, Func] = ???
type FuncId[T] = T

object DoesNotCompile {
  class Bla {
    type Alias[T] = Expected[T, FuncId]
    def bla[T](expected : Alias[T]) : Unit = {}
  }
  (new Bla).bla(2) //type mismatch
}

object Compiles1 { //Compiles with alias placed in different scope
  type Alias[T] = Expected[T, FuncId]
  class Bla {
    def bla[T](expected : Alias[T]) : Unit = {}
  }
  (new Bla).bla(2)
}

object Compiles2 { //Compiles if the call to `bla` is separated from object creation
  class Bla {
    type Alias[T] = Expected[T, FuncId]
    def bla[T](expected : Alias[T]) : Unit = {}
  }
  val a = new Bla
  a.bla(2)
}

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