[cfe] Add test to verify issue 31767 has been fixed

Closes #31767

Change-Id: I729514a172a924fb96183a9ba7978ae347560d5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170821
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2020-11-09 10:28:23 +00:00 committed by commit-bot@chromium.org
parent 1930c07cd7
commit f27e0f96b4
7 changed files with 457 additions and 0 deletions

View file

@ -0,0 +1,61 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart=2.9
import 'issue31767_lib.dart';
StringBuffer sb;
class C {
final int w;
C.foo(int x, [int y = 0, int z = 0]) : w = p("x", x) + p("y", y) + p("z", z);
}
int p(String name, int value) {
sb.write("$name = $value, ");
return value;
}
mixin M on C {
int get w2 => w * w;
}
class D = C with M;
mixin N on A {
int get w2 => w * w;
}
class E = A with N;
main() {
sb = new StringBuffer();
var a = A.foo(1, 2);
expect('x = 1, y = 2, z = 3, ', sb.toString());
expect(6, a.w);
expect(5, a.a.field);
sb = new StringBuffer();
var c = C.foo(1, 2);
expect('x = 1, y = 2, z = 0, ', sb.toString());
expect(3, c.w);
sb = new StringBuffer();
var d = D.foo(1, 2);
expect('x = 1, y = 2, z = 0, ', sb.toString());
expect(3, d.w);
expect(9, d.w2);
sb = new StringBuffer();
var e = E.foo(1, 2);
expect('x = 1, y = 2, z = 3, ', sb.toString());
expect(6, e.w);
expect(36, e.w2);
expect(5, e.a.field);
}
expect(expected, actual) {
if (expected != actual) throw 'Expected $expected, actual $actual';
}

View file

@ -0,0 +1,87 @@
library;
import self as self;
import "dart:core" as core;
import "issue31767_lib.dart" as iss;
import "org-dartlang-testcase:///issue31767_lib.dart";
class C extends core::Object {
final field core::int* w;
constructor foo(core::int* x, [core::int* y, core::int* z]) → self::C*
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
abstract class M extends self::C /*isMixinDeclaration*/ {
get w2() → core::int*
;
}
class D = self::C with self::M {
synthetic constructor foo(core::int* x, [core::int* y, core::int* z]) → self::D*
: super self::C::foo(x, y, z)
;
}
abstract class N extends iss::A /*isMixinDeclaration*/ {
get w2() → core::int*
;
}
class E = iss::A with self::N {
synthetic constructor foo(core::int* x, [core::int* y, core::int* z, iss::_A* a]) → self::E*
: super iss::A::foo(x, y, z, a)
;
}
static field core::StringBuffer* sb;
static method p(core::String* name, core::int* value) → core::int*
;
static method main() → dynamic
;
static method expect(dynamic expected, dynamic actual) → dynamic
;
library;
import self as iss;
import "dart:core" as core;
import "org-dartlang-testcase:///issue31767.dart";
class A extends core::Object {
final field core::int* w;
final field iss::_A* a;
constructor foo(core::int* x, [core::int* y, core::int* z, iss::_A* a]) → iss::A*
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
class _A extends core::Object /*hasConstConstructor*/ {
final field core::int* field;
const constructor •(core::int* field) → iss::_A*
: iss::_A::field = field, super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static const field core::int* _private = 3;

View file

@ -0,0 +1,121 @@
library;
import self as self;
import "dart:core" as core;
import "issue31767_lib.dart" as iss;
import "org-dartlang-testcase:///issue31767_lib.dart";
class C extends core::Object {
final field core::int* w;
constructor foo(core::int* x, [core::int* y = #C1, core::int* z = #C1]) → self::C*
: self::C::w = self::p("x", x).{core::num::+}(self::p("y", y)).{core::num::+}(self::p("z", z)), super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
abstract class M extends self::C /*isMixinDeclaration*/ {
get w2() → core::int*
return this.{self::C::w}.{core::num::*}(this.{self::C::w});
}
class D = self::C with self::M {
synthetic constructor foo(core::int* x, [core::int* y = #C1, core::int* z = #C1]) → self::D*
: super self::C::foo(x, y, z)
;
}
abstract class N extends iss::A /*isMixinDeclaration*/ {
get w2() → core::int*
return this.{iss::A::w}.{core::num::*}(this.{iss::A::w});
}
class E = iss::A with self::N {
synthetic constructor foo(core::int* x, [core::int* y = #C2, core::int* z = #C2, iss::_A* a = #C4]) → self::E*
: super iss::A::foo(x, y, z, a)
;
}
static field core::StringBuffer* sb;
static method p(core::String* name, core::int* value) → core::int* {
self::sb.{core::StringBuffer::write}("${name} = ${value}, ");
return value;
}
static method main() → dynamic {
self::sb = new core::StringBuffer::•();
iss::A* a = new iss::A::foo(1, 2);
self::expect("x = 1, y = 2, z = 3, ", self::sb.{core::StringBuffer::toString}());
self::expect(6, a.{iss::A::w});
self::expect(5, a.{iss::A::a}.{iss::_A::field});
self::sb = new core::StringBuffer::•();
self::C* c = new self::C::foo(1, 2);
self::expect("x = 1, y = 2, z = 0, ", self::sb.{core::StringBuffer::toString}());
self::expect(3, c.{self::C::w});
self::sb = new core::StringBuffer::•();
self::D* d = new self::D::foo(1, 2);
self::expect("x = 1, y = 2, z = 0, ", self::sb.{core::StringBuffer::toString}());
self::expect(3, d.{self::C::w});
self::expect(9, d.{self::M::w2});
self::sb = new core::StringBuffer::•();
self::E* e = new self::E::foo(1, 2);
self::expect("x = 1, y = 2, z = 3, ", self::sb.{core::StringBuffer::toString}());
self::expect(6, e.{iss::A::w});
self::expect(36, e.{self::N::w2});
self::expect(5, e.{iss::A::a}.{iss::_A::field});
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!expected.{core::Object::==}(actual))
throw "Expected ${expected}, actual ${actual}";
}
library;
import self as iss;
import "dart:core" as core;
import "issue31767.dart" as self;
import "org-dartlang-testcase:///issue31767.dart";
class A extends core::Object {
final field core::int* w;
final field iss::_A* a;
constructor foo(core::int* x, [core::int* y = #C2, core::int* z = #C2, iss::_A* a = #C4]) → iss::A*
: iss::A::a = a, iss::A::w = self::p("x", x).{core::num::+}(self::p("y", y)).{core::num::+}(self::p("z", z)), super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
class _A extends core::Object /*hasConstConstructor*/ {
final field core::int* field;
const constructor •(core::int* field) → iss::_A*
: iss::_A::field = field, super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static const field core::int* _private = #C2;
constants {
#C1 = 0
#C2 = 3
#C3 = 5
#C4 = iss::_A {field:#C3}
}

View file

@ -0,0 +1,125 @@
library;
import self as self;
import "dart:core" as core;
import "issue31767_lib.dart" as iss;
import "org-dartlang-testcase:///issue31767_lib.dart";
class C extends core::Object {
final field core::int* w;
constructor foo(core::int* x, [core::int* y = #C1, core::int* z = #C1]) → self::C*
: self::C::w = self::p("x", x).{core::num::+}(self::p("y", y)).{core::num::+}(self::p("z", z)), super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
abstract class M extends self::C /*isMixinDeclaration*/ {
get w2() → core::int*
return this.{self::C::w}.{core::num::*}(this.{self::C::w});
}
class D extends self::C implements self::M /*isEliminatedMixin*/ {
synthetic constructor foo(core::int* x, [core::int* y = #C1, core::int* z = #C1]) → self::D*
: super self::C::foo(x, y, z)
;
get w2() → core::int*
return this.{self::C::w}.{core::num::*}(this.{self::C::w});
}
abstract class N extends iss::A /*isMixinDeclaration*/ {
get w2() → core::int*
return this.{iss::A::w}.{core::num::*}(this.{iss::A::w});
}
class E extends iss::A implements self::N /*isEliminatedMixin*/ {
synthetic constructor foo(core::int* x, [core::int* y = #C2, core::int* z = #C2, iss::_A* a = #C4]) → self::E*
: super iss::A::foo(x, y, z, a)
;
get w2() → core::int*
return this.{iss::A::w}.{core::num::*}(this.{iss::A::w});
}
static field core::StringBuffer* sb;
static method p(core::String* name, core::int* value) → core::int* {
self::sb.{core::StringBuffer::write}("${name} = ${value}, ");
return value;
}
static method main() → dynamic {
self::sb = new core::StringBuffer::•();
iss::A* a = new iss::A::foo(1, 2);
self::expect("x = 1, y = 2, z = 3, ", self::sb.{core::StringBuffer::toString}());
self::expect(6, a.{iss::A::w});
self::expect(5, a.{iss::A::a}.{iss::_A::field});
self::sb = new core::StringBuffer::•();
self::C* c = new self::C::foo(1, 2);
self::expect("x = 1, y = 2, z = 0, ", self::sb.{core::StringBuffer::toString}());
self::expect(3, c.{self::C::w});
self::sb = new core::StringBuffer::•();
self::D* d = new self::D::foo(1, 2);
self::expect("x = 1, y = 2, z = 0, ", self::sb.{core::StringBuffer::toString}());
self::expect(3, d.{self::C::w});
self::expect(9, d.{self::M::w2});
self::sb = new core::StringBuffer::•();
self::E* e = new self::E::foo(1, 2);
self::expect("x = 1, y = 2, z = 3, ", self::sb.{core::StringBuffer::toString}());
self::expect(6, e.{iss::A::w});
self::expect(36, e.{self::N::w2});
self::expect(5, e.{iss::A::a}.{iss::_A::field});
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!expected.{core::Object::==}(actual))
throw "Expected ${expected}, actual ${actual}";
}
library;
import self as iss;
import "dart:core" as core;
import "issue31767.dart" as self;
import "org-dartlang-testcase:///issue31767.dart";
class A extends core::Object {
final field core::int* w;
final field iss::_A* a;
constructor foo(core::int* x, [core::int* y = #C2, core::int* z = #C2, iss::_A* a = #C4]) → iss::A*
: iss::A::a = a, iss::A::w = self::p("x", x).{core::num::+}(self::p("y", y)).{core::num::+}(self::p("z", z)), super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
class _A extends core::Object /*hasConstConstructor*/ {
final field core::int* field;
const constructor •(core::int* field) → iss::_A*
: iss::_A::field = field, super core::Object::•()
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static const field core::int* _private = #C2;
constants {
#C1 = 0
#C2 = 3
#C3 = 5
#C4 = iss::_A {field:#C3}
}

View file

@ -0,0 +1,21 @@
// @dart = 2.9
import 'issue31767_lib.dart';
StringBuffer sb;
class C {
final int w;
C.foo(int x, [int y = 0, int z = 0]) : w = p("x", x) + p("y", y) + p("z", z);
}
int p(String name, int value) {}
mixin M on C {
int get w2 => w * w;
}
class D = C with M;
mixin N on A {
int get w2 => w * w;
}
class E = A with N;
main() {}
expect(expected, actual) {}

View file

@ -0,0 +1,21 @@
// @dart = 2.9
import 'issue31767_lib.dart';
StringBuffer sb;
class C {
C.foo(int x, [int y = 0, int z = 0]) : w = p("x", x) + p("y", y) + p("z", z);
final int w;
}
class D = C with M;
class E = A with N;
expect(expected, actual) {}
int p(String name, int value) {}
main() {}
mixin M on C {
int get w2 => w * w;
}
mixin N on A {
int get w2 => w * w;
}

View file

@ -0,0 +1,21 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart=2.9
import 'issue31767.dart';
const int _private = 3;
class A {
final int w;
final _A a;
A.foo(int x, [int y = _private, int z = _private, this.a = const _A(5)])
: w = p("x", x) + p("y", y) + p("z", z);
}
class _A {
final int field;
const _A(this.field);
}