redef class PClassdef
redef fun accept_typing(v)
do
+ v.variable_ctx = new RootVariableContext(v, self)
+ v.base_variable_ctx = v.variable_ctx
v.self_var = new ParamVariable("self".to_symbol, self)
v.self_var.stype = local_class.get_type
super
redef class AAttrPropdef
redef fun accept_typing(v)
do
+ var old_var_ctx = v.variable_ctx
+ v.variable_ctx = old_var_ctx.sub(self)
super
if n_expr != null then
v.check_conform_expr(n_expr.as(not null), prop.signature.return_type.as(not null))
end
+ v.variable_ctx = old_var_ctx
end
end
var _self_var: nullable ParamVariable
redef fun accept_typing(v)
do
- v.variable_ctx = new RootVariableContext(v, self)
- v.base_variable_ctx = v.variable_ctx
+ var old_var_ctx = v.variable_ctx
+ v.variable_ctx = old_var_ctx.sub(self)
_self_var = v.self_var
super
+ v.variable_ctx = old_var_ctx
end
end
redef class AConcreteMethPropdef
- redef fun accept_typing(v)
+ redef fun after_typing(v)
do
super
if v.variable_ctx.unreash == false and method.signature.return_type != null then
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ readable var _i: Int = foo
+ fun foo: Int do return 1
+ init do end
+end
+
+class B
+ readable var _a: A = bar
+ fun bar: A do return new A
+ init do end
+end
+
+(new A).i.output
+(new B).a.i.output