Skip to content

ExplicitResultTypes generate invalid code when use type lambda #1129

Open
@xuwei-k

Description

@xuwei-k

step

project/build.properties

sbt.version=1.3.10

project/scalafix.sbt

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.15")

build.sbt

scalaVersion := "2.12.11"

Main.scala

trait Functor[F[_]]

object Main {
  def foo[A] = new Functor[({type l[x] = Either[A, x]})#l]{}
}

run sbt scalafixEnable "scalafix ExplicitResultTypes" compile

result

trait Functor[F[_]]

object Main {
-  def foo[A] = new Functor[({type l[x] = Either[A, x]})#l]{}
+  def foo[A]: Functor[Either[A,x]] = new Functor[({type l[x] = Either[A, x]})#l]{}
}
[error] /Users/kenji/type-lambda-scalafix/Main.scala:4:32: not found: type x
[error]   def foo[A]: Functor[Either[A,x]] = new Functor[({type l[x] = Either[A, x]})#l]{}
[error]                                ^
[error] /Users/kenji/type-lambda-scalafix/Main.scala:4:23: Either[A,<error>] takes no type parameters, expected: one
[error]   def foo[A]: Functor[Either[A,x]] = new Functor[({type l[x] = Either[A, x]})#l]{}
[error]                       ^
[error] two errors found
[error] (Compile / compileIncremental) Compilation failed

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