nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/core: remove ascii method on Int and 'b' prefix
[nit.git]
/
src
/
semantize
/
typing.nit
diff --git
a/src/semantize/typing.nit
b/src/semantize/typing.nit
index
1555050
..
3463b07
100644
(file)
--- a/
src/semantize/typing.nit
+++ b/
src/semantize/typing.nit
@@
-36,7
+36,7
@@
private class TypeVisitor
# The module of the analysis
# Used to correctly query the model
# The module of the analysis
# Used to correctly query the model
- var mmodule: MModule
+ var mmodule: MModule is noinit
# The static type of the receiver
# Mainly used for type tests and type resolutions
# The static type of the receiver
# Mainly used for type tests and type resolutions
@@
-60,6
+60,7
@@
private class TypeVisitor
do
var mpropdef = self.mpropdef
var mclassdef = mpropdef.mclassdef
do
var mpropdef = self.mpropdef
var mclassdef = mpropdef.mclassdef
+ mmodule = mclassdef.mmodule
self.mclassdef = mclassdef
self.anchor = mclassdef.bound_mtype
self.mclassdef = mclassdef
self.anchor = mclassdef.bound_mtype
@@
-274,7
+275,7
@@
private class TypeVisitor
fun resolve_mtype(node: AType): nullable MType
do
fun resolve_mtype(node: AType): nullable MType
do
- return self.modelbuilder.resolve_mtype(mmodule, mclassdef, node)
+ return self.modelbuilder.resolve_mtype(mclassdef, node)
end
fun try_get_mclass(node: ANode, name: String): nullable MClass
end
fun try_get_mclass(node: ANode, name: String): nullable MClass
@@
-860,7
+861,7
@@
redef class AMethPropdef
var mpropdef = self.mpropdef
if mpropdef == null then return # skip error
var mpropdef = self.mpropdef
if mpropdef == null then return # skip error
- var v = new TypeVisitor(modelbuilder, mpropdef.mclassdef.mmodule, mpropdef)
+ var v = new TypeVisitor(modelbuilder, mpropdef)
self.selfvariable = v.selfvariable
var mmethoddef = self.mpropdef.as(not null)
self.selfvariable = v.selfvariable
var mmethoddef = self.mpropdef.as(not null)
@@
-927,7
+928,7
@@
redef class AAttrPropdef
var mpropdef = self.mreadpropdef
if mpropdef == null or mpropdef.msignature == null then return # skip error
var mpropdef = self.mreadpropdef
if mpropdef == null or mpropdef.msignature == null then return # skip error
- var v = new TypeVisitor(modelbuilder, mpropdef.mclassdef.mmodule, mpropdef)
+ var v = new TypeVisitor(modelbuilder, mpropdef)
self.selfvariable = v.selfvariable
var nexpr = self.n_expr
self.selfvariable = v.selfvariable
var nexpr = self.n_expr
@@
-1576,9
+1577,7
@@
end
redef class ACharExpr
redef fun accept_typing(v) do
var mclass: nullable MClass = null
redef class ACharExpr
redef fun accept_typing(v) do
var mclass: nullable MClass = null
- if is_ascii then
- mclass = v.get_mclass(self, "Byte")
- else if is_code_point then
+ if is_code_point then
mclass = v.get_mclass(self, "Int")
else
mclass = v.get_mclass(self, "Char")
mclass = v.get_mclass(self, "Int")
else
mclass = v.get_mclass(self, "Char")
@@
-2016,6
+2015,10
@@
redef class AEqFormExpr
if mtype == null or mtype2 == null then return
if mtype == null or mtype2 == null then return
+ if mtype == v.type_bool(self) and (n_expr2 isa AFalseExpr or n_expr2 isa ATrueExpr) then
+ v.modelbuilder.warning(self, "useless-truism", "Warning: useless comparison to a Bool literal.")
+ end
+
if not mtype2 isa MNullType then return
v.check_can_be_null(n_expr, mtype)
if not mtype2 isa MNullType then return
v.check_can_be_null(n_expr, mtype)