I know, it’s illogical to ask but still, I tried declaring a class as abstract and final and I was able to do that.
Does anyone know why is this possible? I don’t see any logical usage of such construct.
Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60).
Type in expressions for evaluation. Or try :help.
scala> abstract final class Person
defined class Person
scala> class Employee extends Person
<console>:12: error: illegal inheritance from final class Person
class Employee extends Person
final abstract class Person
trait Namer[T] { def name: String}
val personNamer = new Namer[Person] { def name: String = “person” }
def [T] printName(namer: Namer[T]) = println(s"It’s a ${namer.name}!")
A type never instantiated but still playing a role in type-checking it
called a phantom type.