nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
typing: Make `TypeVisitor::mmodule` implicit
[nit.git]
/
src
/
semantize
/
typing.nit
diff --git
a/src/semantize/typing.nit
b/src/semantize/typing.nit
index
0bbe61b
..
37a1494
100644
(file)
--- a/
src/semantize/typing.nit
+++ b/
src/semantize/typing.nit
@@
-36,17
+36,17
@@
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
- var anchor: nullable MClassType = null
+ var anchor: MClassType is noinit
# The analyzed mclassdef
# The analyzed mclassdef
- var mclassdef: nullable MClassDef = null
+ var mclassdef: MClassDef is noinit
# The analyzed property
# The analyzed property
- var mpropdef: nullable MPropDef
+ var mpropdef: MPropDef
var selfvariable = new Variable("self")
var selfvariable = new Variable("self")
@@
-59,33
+59,25
@@
private class TypeVisitor
init
do
var mpropdef = self.mpropdef
init
do
var mpropdef = self.mpropdef
+ var mclassdef = mpropdef.mclassdef
+ mmodule = mclassdef.mmodule
+ self.mclassdef = mclassdef
+ self.anchor = mclassdef.bound_mtype
- if mpropdef != null then
- self.mpropdef = mpropdef
- var mclassdef = mpropdef.mclassdef
- self.mclassdef = mclassdef
- self.anchor = mclassdef.bound_mtype
-
- var mclass = mclassdef.mclass
+ var mclass = mclassdef.mclass
- var selfvariable = new Variable("self")
- self.selfvariable = selfvariable
- selfvariable.declared_type = mclass.mclass_type
+ var selfvariable = new Variable("self")
+ self.selfvariable = selfvariable
+ selfvariable.declared_type = mclass.mclass_type
- var mprop = mpropdef.mproperty
- if mprop isa MMethod and mprop.is_new then
- is_toplevel_context = true
- end
+ var mprop = mpropdef.mproperty
+ if mprop isa MMethod and mprop.is_new then
+ is_toplevel_context = true
end
end
fun anchor_to(mtype: MType): MType
do
end
end
fun anchor_to(mtype: MType): MType
do
- var anchor = anchor
- if anchor == null then
- assert not mtype.need_anchor
- return mtype
- end
return mtype.anchor_to(mmodule, anchor)
end
return mtype.anchor_to(mmodule, anchor)
end
@@
-745,7
+737,7
@@
end
class CallSite
super MEntity
class CallSite
super MEntity
- redef var location: Location
+ redef var location
# The static type of the receiver (possibly unresolved)
var recv: MType
# The static type of the receiver (possibly unresolved)
var recv: MType
@@
-790,11
+782,13
@@
class CallSite
fun dump_info(v: ASTDump): String do
return "{recv}.{mpropdef}{msignature}"
end
fun dump_info(v: ASTDump): String do
return "{recv}.{mpropdef}{msignature}"
end
+
+ redef fun mdoc_or_fallback do return mproperty.intro.mdoc
end
redef class Variable
# The declared type of the variable
end
redef class Variable
# The declared type of the variable
- var declared_type: nullable MType is writable
+ var declared_type: nullable MType = null is writable
# Was the variable type-adapted?
# This is used to speedup type retrieval while it remains `false`
# Was the variable type-adapted?
# This is used to speedup type retrieval while it remains `false`
@@
-867,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)
@@
-934,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
@@
-2145,7
+2139,6
@@
redef class ASuperExpr
redef fun accept_typing(v)
do
var anchor = v.anchor
redef fun accept_typing(v)
do
var anchor = v.anchor
- assert anchor != null
var recvtype = v.get_variable(self, v.selfvariable)
assert recvtype != null
var mproperty = v.mpropdef.mproperty
var recvtype = v.get_variable(self, v.selfvariable)
assert recvtype != null
var mproperty = v.mpropdef.mproperty
@@
-2184,7
+2177,6
@@
redef class ASuperExpr
private fun process_superinit(v: TypeVisitor)
do
var anchor = v.anchor
private fun process_superinit(v: TypeVisitor)
do
var anchor = v.anchor
- assert anchor != null
var recvtype = v.get_variable(self, v.selfvariable)
assert recvtype != null
var mpropdef = v.mpropdef
var recvtype = v.get_variable(self, v.selfvariable)
assert recvtype != null
var mpropdef = v.mpropdef