Skip to content

Eta-expansion working for implicit fails on implicit erased #4509

Closed
@Glavo

Description

@Glavo

Trying to compile this code will cause a compilation error

object Main {
  def fun(op: implicit erased (Int) => Unit) = op(0)
  fun { }
}
sbt:dotty-simple> compile
[info] Compiling 1 Scala source to /home/glavo/Projects/dotty-projects/test/target/scala-0.8/classes ...
[error] -- [E007] Type Mismatch Error: /home/glavo/Projects/dotty-projects/test/src/main/scala/org/glavo/Main.scala:5:9 
[error] 5 |  fun { }
[error]   |         ^
[error]   |         found:    Unit
[error]   |         required: erased implicit Int => Unit
[error]   |         
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed 2018-5-11 2:05:16

But this code can be compiled:

object Main {
  def fun(op: implicit (Int) => Unit) = op(0)
  fun { }
}

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