bug
bug copied to clipboard
Self type prevents recognition of SAM type
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
@dwijnand surely this is a bug, not an enhancement?
When I uncomment the line, I get two errors.
@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").
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.
I've edited the issue title, as the interaction-at-a-distance angle isn't currently reproducible.
Scala 3.3.1 accepts both lines.