nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
typing: ANew distinguish the type of the class and the returned type
[nit.git]
/
src
/
semantize
/
typing.nit
diff --git
a/src/semantize/typing.nit
b/src/semantize/typing.nit
index
3aa87a8
..
8c648a0
100644
(file)
--- a/
src/semantize/typing.nit
+++ b/
src/semantize/typing.nit
@@
-1680,11
+1680,13
@@
redef class ANewExpr
# The constructor invoked by the new.
var callsite: nullable CallSite
# The constructor invoked by the new.
var callsite: nullable CallSite
+ # The designated type
+ var recvtype: nullable MClassType
+
redef fun accept_typing(v)
do
var recvtype = v.resolve_mtype(self.n_type)
if recvtype == null then return
redef fun accept_typing(v)
do
var recvtype = v.resolve_mtype(self.n_type)
if recvtype == null then return
- self.mtype = recvtype
if not recvtype isa MClassType then
if recvtype isa MNullableType then
if not recvtype isa MClassType then
if recvtype isa MNullableType then
@@
-1704,6
+1706,8
@@
redef class ANewExpr
end
end
end
end
+ self.recvtype = recvtype
+
var name: String
var nid = self.n_id
if nid != null then
var name: String
var nid = self.n_id
if nid != null then
@@
-1714,6
+1718,13
@@
redef class ANewExpr
var callsite = v.get_method(self, recvtype, name, false)
if callsite == null then return
var callsite = v.get_method(self, recvtype, name, false)
if callsite == null then return
+ if not callsite.mproperty.is_new then
+ self.mtype = recvtype
+ else
+ self.mtype = callsite.msignature.return_mtype
+ assert self.mtype != null
+ end
+
self.callsite = callsite
if not callsite.mproperty.is_init_for(recvtype.mclass) then
self.callsite = callsite
if not callsite.mproperty.is_init_for(recvtype.mclass) then