Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nitmetric fixes #2533

Merged
merged 2 commits into from Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/metrics/detect_covariance.nit
Expand Up @@ -473,19 +473,19 @@ redef class MType
end
#print "4.is {sub} a {sup}? <- no more resolution"

assert sub isa MClassType # It is the only remaining type

# A unfixed formal type can only accept itself
if sup isa MFormalType then
return false
if sub isa MBottomType or sub isa MErrorType then
return true
end

if sup isa MNullType then
# `sup` accepts only null
assert sub isa MClassType else print_error "{sub} <? {sup}" # It is the only remaining type

# Handle sup-type when the sub-type is class-based (other cases must have be identified before).
if sup isa MFormalType or sup isa MNullType or sup isa MBottomType or sup isa MErrorType then
# These types are not super-types of Class-based types.
return false
end

assert sup isa MClassType # It is the only remaining type
assert sup isa MClassType else print_error "got {sup} {sub.inspect}" # It is the only remaining type

# Now both are MClassType, we need to dig

Expand Down
5 changes: 3 additions & 2 deletions src/metrics/static_types_metrics.nit
Expand Up @@ -53,8 +53,9 @@ private class ATypeCounterVisitor
do
if n isa AAnnotation then return

if n isa AType then
var mclassdef = self.nclassdef.mclassdef.as(not null)
if n isa AType then do
var mclassdef = self.nclassdef.mclassdef
if mclassdef == null then break
var mtype = modelbuilder.resolve_mtype(mclassdef, n)
if mtype != null then
self.typecount.inc(mtype)
Expand Down