typing: ANew accepts only `init` on concrete class
authorJean Privat <jean@pryen.org>
Thu, 23 Oct 2014 14:12:12 +0000 (10:12 -0400)
committerJean Privat <jean@pryen.org>
Fri, 24 Oct 2014 23:55:55 +0000 (19:55 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/typing.nit

index 13b36b6..67021b7 100644 (file)
@@ -1711,11 +1711,9 @@ redef class ANewExpr
                if callsite == null then return
 
                if not callsite.mproperty.is_new then
-                       if recvtype.mclass.kind == abstract_kind then
-                               v.error(self, "Cannot instantiate abstract class {recvtype}.")
-                               return
-                       else if recvtype.mclass.kind == interface_kind then
-                               v.error(self, "Cannot instantiate interface {recvtype}.")
+                       var kind = recvtype.mclass.kind
+                       if kind != concrete_kind then
+                               v.error(self, "Cannot instantiate {kind} {recvtype}.")
                                return
                        end
                        self.mtype = recvtype