Fix super constructor calls of anonymous objects and local classes

If a class inherits from another class which captures something (outer class
instance, receiver parameter, local variables, etc.), the constructor of the
former class should contain all the parameters of the super constructor as its
own parameters, so that it could make a proper super call. All such parameters
are now replicated in the derived constructor with kind = SUPER_CALL_PARAM,
except an instance of the outer class (kind = OUTER), which can be taken from
the derived's own OUTER when it has one, to prevent multiple passing of the
same argument.

Previously it worked only when inheriting from inner classes via a special hack
(ConstructorFrameMap).

Also reuse recently introduced ArgumentGenerator to automatically take care of
default and vararg arguments of super constructor

 #KT-3581 Fixed
 #KT-5342 Fixed
 #KT-5343 Fixed
This commit is contained in:
Alexander Udalov
2014-07-15 18:11:26 +04:00
parent b85a672052
commit 65c21561a4
19 changed files with 417 additions and 61 deletions
@@ -0,0 +1,15 @@
fun box(): String {
class Local {
open inner class Inner(val s: String) {
open fun result() = "Fail"
}
val realResult = "OK"
val obj = object : Inner(realResult) {
override fun result() = s
}
}
return Local().obj.result()
}