Skip to content

Eta-expansion of structural types under Scala2 mode #4026

Closed
@allanrenucci

Description

@allanrenucci

Under Scala2 mode this does not compile:

import scala.reflect.Selectable.reflectiveSelectable

class Test {
  def test(x: { def get(): Int }): Int = x.get
                                      // ^
                                      // found:    () => Int
                                      // required: Int
}

This is inconsistent with non structural types and a breaking change with respect to Scala2

def foo(): Int = 1
val x: Int = foo // OK under Scala2 mode

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