Closed
Description
This is a part of #47525.
co19/LanguageFeatures/Super-parameters/semantics_A06_t10
test fails with RuntimeError on the VM because default values of super-parameters are incorrect.
class S {
int s1;
int s2;
S(this.s1, [this.s2 = 42]);
}
class C extends S {
int i1;
int i2;
C(this.i1, super.s1, int x, [super.s2]) : this.i2 = x;
}
Kernel:
class S extends core::Object {
field core::int s1;
field core::int s2;
constructor •(core::int s1, [core::int s2 = #C1]) → sem::S
: sem::S::s1 = s1, sem::S::s2 = s2, super core::Object::•()
;
}
class C extends sem::S {
field core::int i1;
field core::int i2;
constructor •(core::int i1 = #C1, core::int s1, core::int x, [core::int s2 = #C2]) → sem::C
: sem::C::i1 = i1, sem::C::i2 = x, super sem::S::•(s1, s2)
;
}
#C1 = 42
#C2 = null
Here s2
parameter in C
should have a default value #C1
(42), but it has a default value #C2
(null). Parameter i1
is not optional, so it shouldn't have a default value at all.