Skip to content

Fix #4611 #4723

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

Merged
merged 1 commit into from
Aug 20, 2018
Merged

Fix #4611 #4723

merged 1 commit into from
Aug 20, 2018

Conversation

allanrenucci
Copy link
Contributor

class and trait with a single abstract method which result type is an
implicit function type are not considered SAM types anymore. The reason
is because the abstract member desugar to mutiple ones. E.g.

trait Foo {
  def foo(): implicit Int => Int
}

// becomes
trait Foo {
  def foo(): implicit Int => Int
  def foo$direct(implicit x: Int): Int
}

@allanrenucci allanrenucci changed the title Fix #4611: Fix #4611 Jun 26, 2018
@allanrenucci
Copy link
Contributor Author

An alternative fix which did not introduce this restriction on SAM types was tried in #4621.

For now this fixes the compiler crash. In the future, if one wants to try again and lift the restriction, implicitFuns2.scala is a very good test case

@allanrenucci
Copy link
Contributor Author

Blocked on #4753

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a testcase where the implicit result type comes from a type parameter e.g.:

trait Foo[T] {
  def bla(x: Int): T
}

val a: Foo[implicit Int => Int] = (x: Int) => 1 // error

@@ -3837,7 +3837,7 @@ object Types {
* A type is a SAM type if it is a reference to a class or trait, which
*
* - has a single abstract method with a method type (ExprType
* and PolyType not allowed!)
* and PolyType not allowed!) which result type is not an implicit function type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which -> whose

class and trait with a single abstract method which result type is an
implicit function type are not considered SAM types anymore. The reason
is because the abstract member desugar to mutiple ones. E.g.

```scala
trait Foo {
  def foo(): implicit Int => Int
}

// becomes
trait Foo {
  def foo(): implicit Int => Int
  def foo$direct(implicit x: Int): Int
}
```
@allanrenucci allanrenucci merged commit d6df02b into scala:master Aug 20, 2018
@allanrenucci allanrenucci deleted the fix-4611-v2 branch August 20, 2018 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants