typing: warnings related to adaptive typing are moved to the post_typing
[nit.git] / src / metrics / detect_covariance.nit
index 9090658..ef403a3 100644 (file)
@@ -318,7 +318,7 @@ redef class TypeVisitor
 
        fun dcp: DetectCovariancePhase do return modelbuilder.toolcontext.detect_covariance_phase
 
-       redef fun visit_expr_cast(node, nexpr, ntype)
+       redef fun check_expr_cast(node, nexpr, ntype)
        do
                var sub = super
 
@@ -343,7 +343,7 @@ redef class TypeVisitor
                return sub
        end
 
-       redef fun check_subtype(node: ANode, sub, sup: MType): nullable MType
+       redef fun check_subtype(node: ANode, sub, sup: MType, autocast: Bool): nullable MType
        do
                var res = super
 
@@ -361,6 +361,9 @@ redef class TypeVisitor
                        if node isa AAsCastExpr then
                                return res
                        end
+                       if not autocast then
+                               return res
+                       end
                        sup = supx.resolve_for(anchor.mclass.mclass_type, anchor, mmodule, true)
                        if self.is_subtype(sub, sup) then
                                dcp.cpt_autocast.inc("vt")
@@ -371,7 +374,7 @@ redef class TypeVisitor
                                        dcp.cpt_autocast.inc("vt+pt")
                                        dcp.count_cast(node, supx, sub, mmodule, anchor)
                                else
-                                       self.modelbuilder.error(node, "Type error: expected {sup}, got {sub}")
+                                       self.modelbuilder.error(node, "Type Error: expected `{sup}`, got `{sub}`")
                                        return null
                                end
                        end