so, one could write
~~~
interface A
fun foo: String
end
class B
super A
redef var foo # var foo is a String!
end
~~~
Signed-off-by: Jean Privat <jean@pryen.org>
var mmodule = mclassdef.mmodule
var mtype: nullable MType = null
var mmodule = mclassdef.mmodule
var mtype: nullable MType = null
+ var mreadpropdef = self.mreadpropdef
+
var ntype = self.n_type
if ntype != null then
mtype = modelbuilder.resolve_mtype(mmodule, mclassdef, ntype)
if mtype == null then return
end
var ntype = self.n_type
if ntype != null then
mtype = modelbuilder.resolve_mtype(mmodule, mclassdef, ntype)
if mtype == null then return
end
+ # Inherit the type from the getter (usually an abstact getter)
+ if mtype == null and mreadpropdef != null and not mreadpropdef.is_intro then
+ var msignature = mreadpropdef.mproperty.intro.msignature
+ if msignature == null then return # Error, thus skiped
+ mtype = msignature.return_mtype
+ end
+
var nexpr = self.n_expr
if mtype == null then
if nexpr != null then
var nexpr = self.n_expr
if mtype == null then
if nexpr != null then
modelbuilder.error(self, "Error: Untyped attribute {mpropdef}. Implicit typing allowed only for literals and new.")
end
modelbuilder.error(self, "Error: Untyped attribute {mpropdef}. Implicit typing allowed only for literals and new.")
end
- else
- modelbuilder.error(self, "Error: Untyped attribute {mpropdef}")
+ if mtype == null then return
- else
- assert ntype != null
+ else if ntype != null then
if nexpr isa ANewExpr then
var xmtype = modelbuilder.resolve_mtype(mmodule, mclassdef, nexpr.n_type)
if xmtype == mtype and modelbuilder.toolcontext.opt_warn.value >= 2 then
if nexpr isa ANewExpr then
var xmtype = modelbuilder.resolve_mtype(mmodule, mclassdef, nexpr.n_type)
if xmtype == mtype and modelbuilder.toolcontext.opt_warn.value >= 2 then
- if mtype == null then return
+ if mtype == null then
+ modelbuilder.error(self, "Error: Untyped attribute {mpropdef}")
+ return
+ end
mpropdef.static_mtype = mtype
mpropdef.static_mtype = mtype
- var mreadpropdef = self.mreadpropdef
if mreadpropdef != null then
var msignature = new MSignature(new Array[MParameter], mtype)
mreadpropdef.msignature = msignature
if mreadpropdef != null then
var msignature = new MSignature(new Array[MParameter], mtype)
mreadpropdef.msignature = msignature