Pre-evaluation for methods
iusildra opened this issue · comments
Actually, among all the node of RuntimeTree
, only those that can be evaluated by reading a value (InstanceFieldTree
, TopLevelModuleTree
...) can be pre-evaluated. Methods cannot for safety reasons.
But what if, once the validation is done and the evaluation started, the value's type returned by a method call would differ from the expected type ? We could revalidate the expression to access more precise members. For instance
class A
class B extends A { val b = "b" }
def test: A = new B
test.b // could return "b"
But what if, once the validation is done and the evaluation started, the value's type returned by a method call would differ from the expected type ? We could revalidate the expression to access more precise members. For instance
How would that be useful? It is valid it can already be evaluated and all evaluations should return the same result.
If we call fields/methods declared in the general type, yes, but if we call a member that exist only in the more specific type, it won't be validated
once the validation is done and the evaluation started
If you cant prove that the expression is correct, why would you start the evaluation ? There is a risk that the method has side effect and that the expression still cannot be validated on the more precise type.
True, I think I achieved to confuse myself 😀