Skip to content

Extension methods and match types cause undue compilation errors #8650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
felixmulder opened this issue Apr 1, 2020 · 1 comment
Closed
Assignees

Comments

@felixmulder
Copy link
Contributor

felixmulder commented Apr 1, 2020

Minimized code

// This is crazy:
type Get0 = OK_BOOMER[Int, Unit]
def get0: Handler[Get0] = IO[Unit]()

type Get1 = OK_BOOMER[Boolean, Unit]
def get1: Handler[Get1] = IO[Unit]()

// compiles:
type API = Get0 :<|> Get1
def api0: API = HandlerAlt(get0, get1)

// does not compile:
extension ops:
  def [A,B](left: Handler[A]) :<|> (right: Handler[B]): HandlerAlt[A, B] =
    HandlerAlt(left, right)

import ops._
def api1: API =
  get0 :<|> get1


class HandlerAlt[A, B](left: Handler[A], right: Handler[B])

type :<|>[A,B] = HandlerAlt[A, B]

case class IO[A]()
case class OK_BOOMER[A, B]()

type Handler[API] = handler.Go[API]

object handler:
  // Starter for Handler reduction:
  type Go[API] = API match
    case _ =>
      HandlerSingle[API]

  type HandlerSingle[X] = X match
    case OK_BOOMER[_, response] =>
      IO[response]

Output

[error] -- [E008] Not Found Error: /Users/fixel/.src/serviteur/src/main/scala/serviteur/minimized.scala:19:7
[error] 19 |  get0 :<|> get1
[error]    |  ^^^^^^^^^
[error]    |  value :<|> is not a member of handler.Go[Get0]

Expectation

It compiles

@smarter
Copy link
Member

smarter commented Apr 5, 2020

As far as I can tell, same problem as #8666 (comment): the extension method cannot be resolved since the type system has no idea that get0 is a valid argument for def [A,B](left: Handler[A])

@smarter smarter closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants