Skip to content

Commit 481f2b3

Browse files
alexmarkovCommit Queue
authored and
Commit Queue
committed
[vm] Fix noSuchMethod forwarding stubs in mixin applications
TEST=pkg/front_end/testcases/no_such_method_forwarders/regress_* Fixes #53677 Fixes #53676 Fixes #53656 Fixes #53640 Change-Id: I282a57a6aa4d3d55235ff0fb2c1d9b8470c49c93 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329565 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 1dec944 commit 481f2b3

37 files changed

+1548
-9
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
class C {
6+
int m();
7+
dynamic noSuchMethod(Invocation i) => "C";
8+
}
9+
10+
mixin M {
11+
int m();
12+
dynamic noSuchMethod(Invocation i) => "M";
13+
}
14+
15+
class MA = Object with M;
16+
17+
throws(void Function() f) {
18+
try {
19+
f();
20+
} on TypeError catch (e) {
21+
print(e);
22+
return;
23+
}
24+
throw 'Missing TypeError';
25+
}
26+
27+
main() {
28+
// Unhandled exception: type 'String' is not a subtype of type 'int'
29+
throws(() => C().m());
30+
throws(() => MA().m());
31+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class C extends core::Object {
6+
synthetic constructor •() → self::C
7+
: super core::Object::•()
8+
;
9+
no-such-method-forwarder method m() → core::int
10+
return this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
11+
method noSuchMethod(core::Invocation i) → dynamic
12+
return "C";
13+
}
14+
abstract class M extends core::Object /*isMixinDeclaration*/ {
15+
abstract method m() → core::int;
16+
method noSuchMethod(core::Invocation i) → dynamic
17+
return "M";
18+
}
19+
class MA = core::Object with self::M /*hasConstConstructor*/ {
20+
const synthetic constructor •() → self::MA
21+
: super core::Object::•()
22+
;
23+
mixin-super-stub method noSuchMethod(core::Invocation i) → dynamic
24+
return super.{self::M::noSuchMethod}(i);
25+
no-such-method-forwarder method m() → core::int
26+
return this.{self::MA::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
27+
}
28+
static method throws(() → void f) → dynamic {
29+
try {
30+
f(){() → void};
31+
}
32+
on core::TypeError catch(final core::TypeError e) {
33+
core::print(e);
34+
return;
35+
}
36+
throw "Missing TypeError";
37+
}
38+
static method main() → dynamic {
39+
self::throws(() → void => new self::C::•().{self::C::m}(){() → core::int});
40+
self::throws(() → void => new self::MA::•().{self::MA::m}(){() → core::int});
41+
}
42+
43+
constants {
44+
#C1 = #m
45+
#C2 = <core::Type*>[]
46+
#C3 = <dynamic>[]
47+
#C4 = <core::Symbol*, dynamic>{}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class C extends core::Object {
6+
synthetic constructor •() → self::C
7+
: super core::Object::•()
8+
;
9+
no-such-method-forwarder method m() → core::int
10+
return this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
11+
method noSuchMethod(core::Invocation i) → dynamic
12+
return "C";
13+
}
14+
abstract class M extends core::Object /*isMixinDeclaration*/ {
15+
abstract method m() → core::int;
16+
method noSuchMethod(core::Invocation i) → dynamic
17+
return "M";
18+
}
19+
class MA extends core::Object implements self::M /*isEliminatedMixin,hasConstConstructor*/ {
20+
const synthetic constructor •() → self::MA
21+
: super core::Object::•()
22+
;
23+
method noSuchMethod(core::Invocation i) → dynamic
24+
return "M";
25+
no-such-method-forwarder method m() → core::int
26+
return this.{self::MA::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
27+
}
28+
static method throws(() → void f) → dynamic {
29+
try {
30+
f(){() → void};
31+
}
32+
on core::TypeError catch(final core::TypeError e) {
33+
core::print(e);
34+
return;
35+
}
36+
throw "Missing TypeError";
37+
}
38+
static method main() → dynamic {
39+
self::throws(() → void => new self::C::•().{self::C::m}(){() → core::int});
40+
self::throws(() → void => new self::MA::•().{self::MA::m}(){() → core::int});
41+
}
42+
43+
constants {
44+
#C1 = #m
45+
#C2 = <core::Type*>[]
46+
#C3 = <dynamic>[]
47+
#C4 = <core::Symbol*, dynamic>{}
48+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class C {
2+
int m();
3+
dynamic noSuchMethod(Invocation i) => "C";
4+
}
5+
6+
mixin M {
7+
int m();
8+
dynamic noSuchMethod(Invocation i) => "M";
9+
}
10+
class MA = Object with M;
11+
throws(void Function() f) {}
12+
main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class C {
2+
dynamic noSuchMethod(Invocation i) => "C";
3+
int m();
4+
}
5+
6+
class MA = Object with M;
7+
main() {}
8+
mixin M {
9+
dynamic noSuchMethod(Invocation i) => "M";
10+
int m();
11+
}
12+
throws(void Function() f) {}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class C extends core::Object {
6+
synthetic constructor •() → self::C
7+
: super core::Object::•()
8+
;
9+
no-such-method-forwarder method m() → core::int
10+
return this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
11+
method noSuchMethod(core::Invocation i) → dynamic
12+
return "C";
13+
}
14+
abstract class M extends core::Object /*isMixinDeclaration*/ {
15+
abstract method m() → core::int;
16+
method noSuchMethod(core::Invocation i) → dynamic
17+
return "M";
18+
}
19+
class MA = core::Object with self::M /*hasConstConstructor*/ {
20+
const synthetic constructor •() → self::MA
21+
: super core::Object::•()
22+
;
23+
mixin-super-stub method noSuchMethod(core::Invocation i) → dynamic
24+
return super.{self::M::noSuchMethod}(i);
25+
no-such-method-forwarder method m() → core::int
26+
return this.{self::MA::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
27+
}
28+
static method throws(() → void f) → dynamic {
29+
try {
30+
f(){() → void};
31+
}
32+
on core::TypeError catch(final core::TypeError e) {
33+
core::print(e);
34+
return;
35+
}
36+
throw "Missing TypeError";
37+
}
38+
static method main() → dynamic {
39+
self::throws(() → void => new self::C::•().{self::C::m}(){() → core::int});
40+
self::throws(() → void => new self::MA::•().{self::MA::m}(){() → core::int});
41+
}
42+
43+
constants {
44+
#C1 = #m
45+
#C2 = <core::Type*>[]
46+
#C3 = <dynamic>[]
47+
#C4 = <core::Symbol*, dynamic>{}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class C extends core::Object {
6+
synthetic constructor •() → self::C
7+
: super core::Object::•()
8+
;
9+
no-such-method-forwarder method m() → core::int
10+
return this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
11+
method noSuchMethod(core::Invocation i) → dynamic
12+
return "C";
13+
}
14+
abstract class M extends core::Object /*isMixinDeclaration*/ {
15+
abstract method m() → core::int;
16+
method noSuchMethod(core::Invocation i) → dynamic
17+
return "M";
18+
}
19+
class MA = core::Object with self::M /*hasConstConstructor*/ {
20+
const synthetic constructor •() → self::MA
21+
: super core::Object::•()
22+
;
23+
mixin-super-stub method noSuchMethod(core::Invocation i) → dynamic
24+
return super.{self::M::noSuchMethod}(i);
25+
no-such-method-forwarder method m() → core::int
26+
return this.{self::MA::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
27+
}
28+
static method throws(() → void f) → dynamic {
29+
try {
30+
f(){() → void};
31+
}
32+
on core::TypeError catch(final core::TypeError e) {
33+
core::print(e);
34+
return;
35+
}
36+
throw "Missing TypeError";
37+
}
38+
static method main() → dynamic {
39+
self::throws(() → void => new self::C::•().{self::C::m}(){() → core::int});
40+
self::throws(() → void => new self::MA::•().{self::MA::m}(){() → core::int});
41+
}
42+
43+
constants {
44+
#C1 = #m
45+
#C2 = <core::Type*>[]
46+
#C3 = <dynamic>[]
47+
#C4 = <core::Symbol*, dynamic>{}
48+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class C extends core::Object {
6+
synthetic constructor •() → self::C
7+
;
8+
no-such-method-forwarder method m() → core::int
9+
return this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#m, 0, const <core::Type*>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol*, dynamic>(const <core::Symbol*, dynamic>{}))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
10+
method noSuchMethod(core::Invocation i) → dynamic
11+
;
12+
}
13+
abstract class M extends core::Object /*isMixinDeclaration*/ {
14+
abstract method m() → core::int;
15+
method noSuchMethod(core::Invocation i) → dynamic
16+
;
17+
}
18+
class MA = core::Object with self::M /*hasConstConstructor*/ {
19+
const synthetic constructor •() → self::MA
20+
: super core::Object::•()
21+
;
22+
mixin-super-stub method noSuchMethod(core::Invocation i) → dynamic
23+
return super.{self::M::noSuchMethod}(i);
24+
no-such-method-forwarder method m() → core::int
25+
return this.{self::MA::noSuchMethod}(new core::_InvocationMirror::_withType(#m, 0, const <core::Type*>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol*, dynamic>(const <core::Symbol*, dynamic>{}))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
26+
}
27+
static method throws(() → void f) → dynamic
28+
;
29+
static method main() → dynamic
30+
;
31+
32+
33+
Extra constant evaluation status:
34+
Evaluated: SymbolLiteral @ org-dartlang-testcase:///regress_53640.dart:6:7 -> SymbolConstant(#m)
35+
Evaluated: ListLiteral @ org-dartlang-testcase:///regress_53640.dart:6:7 -> ListConstant(const <Type*>[])
36+
Evaluated: ListLiteral @ org-dartlang-testcase:///regress_53640.dart:6:7 -> ListConstant(const <dynamic>[])
37+
Evaluated: MapLiteral @ org-dartlang-testcase:///regress_53640.dart:6:7 -> MapConstant(const <Symbol*, dynamic>{})
38+
Evaluated: SymbolLiteral @ org-dartlang-testcase:///regress_53640.dart:15:7 -> SymbolConstant(#m)
39+
Evaluated: ListLiteral @ org-dartlang-testcase:///regress_53640.dart:15:7 -> ListConstant(const <Type*>[])
40+
Evaluated: ListLiteral @ org-dartlang-testcase:///regress_53640.dart:15:7 -> ListConstant(const <dynamic>[])
41+
Evaluated: MapLiteral @ org-dartlang-testcase:///regress_53640.dart:15:7 -> MapConstant(const <Symbol*, dynamic>{})
42+
Extra constant evaluation: evaluated: 20, effectively constant: 8
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class C extends core::Object {
6+
synthetic constructor •() → self::C
7+
: super core::Object::•()
8+
;
9+
no-such-method-forwarder method m() → core::int
10+
return this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
11+
method noSuchMethod(core::Invocation i) → dynamic
12+
return "C";
13+
}
14+
abstract class M extends core::Object /*isMixinDeclaration*/ {
15+
abstract method m() → core::int;
16+
method noSuchMethod(core::Invocation i) → dynamic
17+
return "M";
18+
}
19+
class MA extends core::Object implements self::M /*isEliminatedMixin,hasConstConstructor*/ {
20+
const synthetic constructor •() → self::MA
21+
: super core::Object::•()
22+
;
23+
method noSuchMethod(core::Invocation i) → dynamic
24+
return "M";
25+
no-such-method-forwarder method m() → core::int
26+
return this.{self::MA::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, core::Map::unmodifiable<core::Symbol*, dynamic>(#C4))){(core::Invocation) → dynamic} as{TypeError,ForDynamic} core::int;
27+
}
28+
static method throws(() → void f) → dynamic {
29+
try {
30+
f(){() → void};
31+
}
32+
on core::TypeError catch(final core::TypeError e) {
33+
core::print(e);
34+
return;
35+
}
36+
throw "Missing TypeError";
37+
}
38+
static method main() → dynamic {
39+
self::throws(() → void => new self::C::•().{self::C::m}(){() → core::int});
40+
self::throws(() → void => new self::MA::•().{self::MA::m}(){() → core::int});
41+
}
42+
43+
constants {
44+
#C1 = #m
45+
#C2 = <core::Type*>[]
46+
#C3 = <dynamic>[]
47+
#C4 = <core::Symbol*, dynamic>{}
48+
}

0 commit comments

Comments
 (0)