bug icon indicating copy to clipboard operation
bug copied to clipboard

Self type prevents recognition of SAM type

Open adriaanm opened this issue 9 years ago • 5 comments
trafficstars

from neg/sammy_restrictions.scala:

abstract class NoAbstract
abstract class OneAbstract { def ap(a: Int): Any }
abstract class DerivedOneAbstract extends OneAbstract
abstract class SelfTp { self: NoAbstract => def ap(a: Int): Any }

object Test {
  type NonClassType = DerivedOneAbstract with OneAbstract

//  ((x: Int) => 0): SelfTp

  ((x: Int) => 0): NonClassType // should compile, but only does when the above line is uncommented...
}

Reported in https://groups.google.com/d/msg/scala-internals/lv4sTGorDLU/onfydhVpBAAJ

adriaanm avatar Jun 06 '16 18:06 adriaanm

@dwijnand surely this is a bug, not an enhancement?

NthPortal avatar Oct 22 '20 16:10 NthPortal

When I uncomment the line, I get two errors.

som-snytt avatar Oct 22 '20 19:10 som-snytt

@dwijnand surely this is a bug, not an enhancement?

I've concluded that these matters are subjective. The closest I've found to a good way to discriminating is going off of what a specification says. But even then that's not good enough: see the blocking {} thing and the default execution context and how we're going to revert the change for 2.13.4...

Coming back to this, it was recorded as a feature in scala/scala-dev so I tried to preserve that by using scala/bug's enhancement. But personally I've given up on such labels (also why I sometimes refer to these as "tickets" rather than "issues").

dwijnand avatar Oct 22 '20 20:10 dwijnand

Sounds like a bug to me, likely due to a sub-optimal reduction of a refined type to a symbol while we're trying to decide samminess.

adriaanm avatar Oct 29 '20 08:10 adriaanm

I've edited the issue title, as the interaction-at-a-distance angle isn't currently reproducible.

Scala 3.3.1 accepts both lines.

SethTisue avatar Feb 19 '24 00:02 SethTisue