Skip to content

Double eta-expansion when ascribing contextual types #6375

Closed
@biboudis

Description

@biboudis

When we use a contextual type as a return type

class Test  {
   def f(): given Int => Boolean = true
}

it η-expands once ->

def f(): ImplicitFunction1[Int, Boolean] =  {
   def $anonfun(implicit evidence$1: Int): Boolean = true
   closure($anonfun)
}

However, if we provide an explicit ascription:

class Test  {
   def f(): given Int => Boolean = true : (given Int => Boolean)
}

it expands unnecessarily twice:

def f(): ImplicitFunction1[Int, Boolean] =  {
   def $anonfun(implicit evidence$1: Int): Boolean =  (
      {
         def $anonfun(implicit evidence$2: Int): Boolean = true
         closure($anonfun)
      }:ImplicitFunction1[Int, Boolean]).apply(evidence$1)
   closure($anonfun)
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions