[#415] | project: specification | priority: low | category: missing feature | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Vincent | Martin | won't fix | 2005-04-08 18:08:55.0 | |
subject | Selections on non-path expressions create malformed types | |||
code |
abstract class A { type T <: String; def x: T; } abstract class B { def a: A; val y: String = a.x; } |
|||
what happened | slots.scala:8: malformed type: A#T val y: String = a.x; ^ one error found |
|||
what expected | Silent compilation. I really think the compiler should automatically add temporary stable variables (val) to hold the value of expressions used as receiver objects. In the code above, the compiler should interpret the class B as:
abstract class B { def a: A; val tmp = a; val y: String = tmp.x; } |
|||
[back to overview] |
Martin edited on 2006-03-30 17:57:16.0 |
The problem with the proposed fix is that it is non-local. We could make the temporary variable local, as in val y: String = { val a$ = a; a$.x } but that would produce also an error. |
Martin edited on 2006-10-07 13:24:40.0 |
I have put in a fix that approximates the type from above instead of throwing a malformed exception. This needs to be speced still. |
Martin edited on 2006-10-31 13:36:10.0 |
Martin edited on 2006-12-01 17:30:28.0 |
I got convinced b recent bug reports that hiding this sort of bug is a bad thing. Very often it leads to obscure behavior later on. So I revert the changes to the compiler that approximate types, and leave the spec as it is. |