Skip to content

Commit 1aa7f52

Browse files
Dmitry Stefantsovcommit-bot@chromium.org
authored andcommitted
[fasta] Make forwarding stubs operators if their source are operators
Change-Id: I516c0ac9ccf93770cc331b1c7569df1a1c16659c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102160 Reviewed-by: Aske Simon Christensen <[email protected]>
1 parent 53dde32 commit 1aa7f52

9 files changed

Lines changed: 347 additions & 0 deletions

pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,9 @@ class InterfaceConflict extends DelayedMember {
23132313
ProcedureKind kind = ProcedureKind.Method;
23142314
if (bestSoFar.isField || bestSoFar.isSetter || bestSoFar.isGetter) {
23152315
kind = isSetter ? ProcedureKind.Setter : ProcedureKind.Getter;
2316+
} else if (bestSoFar.target is Procedure &&
2317+
bestSoFar.target.kind == ProcedureKind.Operator) {
2318+
kind = ProcedureKind.Operator;
23162319
}
23172320

23182321
if (modifyKernel) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2019, 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+
//------------------------------------------------------------------------------
6+
7+
class A {
8+
dynamic operator+(covariant int a) => null;
9+
}
10+
11+
class B {
12+
dynamic operator+(dynamic b) => null;
13+
}
14+
15+
abstract class C implements A, B {}
16+
17+
//------------------------------------------------------------------------------
18+
19+
class D {
20+
dynamic operator+(dynamic d) => null;
21+
}
22+
23+
class E extends D {
24+
dynamic operator+(covariant int e);
25+
}
26+
27+
//------------------------------------------------------------------------------
28+
29+
main() {}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Object:
2+
superclasses:
3+
interfaces:
4+
classMembers:
5+
Object._haveSameRuntimeType
6+
Object.toString
7+
Object.runtimeType
8+
Object._toString
9+
Object._simpleInstanceOf
10+
Object._hashCodeRnd
11+
Object._instanceOf
12+
Object.noSuchMethod
13+
Object._objectHashCode
14+
Object._identityHashCode
15+
Object.hashCode
16+
Object._simpleInstanceOfFalse
17+
Object._simpleInstanceOfTrue
18+
Object.==
19+
classSetters:
20+
21+
A:
22+
superclasses:
23+
Object
24+
interfaces:
25+
classMembers:
26+
Object.toString
27+
A.+
28+
Object.runtimeType
29+
Object._simpleInstanceOf
30+
Object._instanceOf
31+
Object.noSuchMethod
32+
Object._identityHashCode
33+
Object.hashCode
34+
Object._simpleInstanceOfFalse
35+
Object._simpleInstanceOfTrue
36+
Object.==
37+
classSetters:
38+
39+
B:
40+
superclasses:
41+
Object
42+
interfaces:
43+
classMembers:
44+
Object.toString
45+
B.+
46+
Object.runtimeType
47+
Object._simpleInstanceOf
48+
Object._instanceOf
49+
Object.noSuchMethod
50+
Object._identityHashCode
51+
Object.hashCode
52+
Object._simpleInstanceOfFalse
53+
Object._simpleInstanceOfTrue
54+
Object.==
55+
classSetters:
56+
57+
C:
58+
Longest path to Object: 2
59+
superclasses:
60+
Object
61+
interfaces: A, B
62+
classMembers:
63+
Object.toString
64+
Object.runtimeType
65+
Object._simpleInstanceOf
66+
Object._instanceOf
67+
Object.noSuchMethod
68+
Object._identityHashCode
69+
Object.hashCode
70+
Object._simpleInstanceOfFalse
71+
Object._simpleInstanceOfTrue
72+
Object.==
73+
classSetters:
74+
interfaceMembers:
75+
Object.toString
76+
C.A.+%B.+
77+
Object.runtimeType
78+
Object._simpleInstanceOf
79+
Object._instanceOf
80+
Object.noSuchMethod
81+
Object._identityHashCode
82+
Object.hashCode
83+
Object._simpleInstanceOfFalse
84+
Object._simpleInstanceOfTrue
85+
Object.==
86+
interfaceSetters:
87+
88+
D:
89+
superclasses:
90+
Object
91+
interfaces:
92+
classMembers:
93+
Object.toString
94+
D.+
95+
Object.runtimeType
96+
Object._simpleInstanceOf
97+
Object._instanceOf
98+
Object.noSuchMethod
99+
Object._identityHashCode
100+
Object.hashCode
101+
Object._simpleInstanceOfFalse
102+
Object._simpleInstanceOfTrue
103+
Object.==
104+
classSetters:
105+
106+
E:
107+
superclasses:
108+
Object
109+
-> D
110+
interfaces:
111+
classMembers:
112+
Object.toString
113+
E.D.+%E.+
114+
Object.runtimeType
115+
Object._simpleInstanceOf
116+
Object._instanceOf
117+
Object.noSuchMethod
118+
Object._identityHashCode
119+
Object.hashCode
120+
Object._simpleInstanceOfFalse
121+
Object._simpleInstanceOfTrue
122+
Object.==
123+
classSetters:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
synthetic constructor •() → self::A
7+
: super core::Object::•()
8+
;
9+
operator +(covariant core::int a) → dynamic
10+
return null;
11+
}
12+
class B extends core::Object {
13+
synthetic constructor •() → self::B
14+
: super core::Object::•()
15+
;
16+
operator +(dynamic b) → dynamic
17+
return null;
18+
}
19+
abstract class C extends core::Object implements self::A, self::B {
20+
synthetic constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
abstract forwarding-stub operator +(covariant dynamic b) → dynamic;
24+
}
25+
class D extends core::Object {
26+
synthetic constructor •() → self::D
27+
: super core::Object::•()
28+
;
29+
operator +(dynamic d) → dynamic
30+
return null;
31+
}
32+
class E extends self::D {
33+
synthetic constructor •() → self::E
34+
: super self::D::•()
35+
;
36+
forwarding-stub forwarding-semi-stub operator +(covariant core::int e) → dynamic
37+
return super.{self::D::+}(e);
38+
}
39+
static method main() → dynamic {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
synthetic constructor •() → self::A
7+
: super core::Object::•()
8+
;
9+
operator +(covariant core::int a) → dynamic
10+
return null;
11+
}
12+
class B extends core::Object {
13+
synthetic constructor •() → self::B
14+
: super core::Object::•()
15+
;
16+
operator +(dynamic b) → dynamic
17+
return null;
18+
}
19+
abstract class C extends core::Object implements self::A, self::B {
20+
synthetic constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
abstract forwarding-stub operator +(covariant dynamic b) → dynamic;
24+
}
25+
class D extends core::Object {
26+
synthetic constructor •() → self::D
27+
: super core::Object::•()
28+
;
29+
operator +(dynamic d) → dynamic
30+
return null;
31+
}
32+
class E extends self::D {
33+
synthetic constructor •() → self::E
34+
: super self::D::•()
35+
;
36+
forwarding-stub forwarding-semi-stub operator +(covariant core::int e) → dynamic
37+
return super.{self::D::+}(e);
38+
}
39+
static method main() → dynamic {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
synthetic constructor •() → self::A
7+
;
8+
operator +(covariant core::int a) → dynamic
9+
;
10+
}
11+
class B extends core::Object {
12+
synthetic constructor •() → self::B
13+
;
14+
operator +(dynamic b) → dynamic
15+
;
16+
}
17+
abstract class C extends core::Object implements self::A, self::B {
18+
synthetic constructor •() → self::C
19+
;
20+
abstract forwarding-stub operator +(covariant dynamic b) → dynamic;
21+
}
22+
class D extends core::Object {
23+
synthetic constructor •() → self::D
24+
;
25+
operator +(dynamic d) → dynamic
26+
;
27+
}
28+
class E extends self::D {
29+
synthetic constructor •() → self::E
30+
;
31+
forwarding-stub forwarding-semi-stub operator +(covariant core::int e) → dynamic
32+
return super.{self::D::+}(e);
33+
}
34+
static method main() → dynamic
35+
;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
synthetic constructor •() → self::A
7+
: super core::Object::•()
8+
;
9+
operator +(covariant core::int a) → dynamic
10+
return null;
11+
}
12+
class B extends core::Object {
13+
synthetic constructor •() → self::B
14+
: super core::Object::•()
15+
;
16+
operator +(dynamic b) → dynamic
17+
return null;
18+
}
19+
abstract class C extends core::Object implements self::A, self::B {
20+
synthetic constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
abstract forwarding-stub operator +(covariant dynamic b) → dynamic;
24+
}
25+
class D extends core::Object {
26+
synthetic constructor •() → self::D
27+
: super core::Object::•()
28+
;
29+
operator +(dynamic d) → dynamic
30+
return null;
31+
}
32+
class E extends self::D {
33+
synthetic constructor •() → self::E
34+
: super self::D::•()
35+
;
36+
forwarding-stub forwarding-semi-stub operator +(covariant core::int e) → dynamic
37+
return super.{self::D::+}(e);
38+
}
39+
static method main() → dynamic {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
synthetic constructor •() → self::A
7+
: super core::Object::•()
8+
;
9+
operator +(covariant core::int a) → dynamic
10+
return null;
11+
}
12+
class B extends core::Object {
13+
synthetic constructor •() → self::B
14+
: super core::Object::•()
15+
;
16+
operator +(dynamic b) → dynamic
17+
return null;
18+
}
19+
abstract class C extends core::Object implements self::A, self::B {
20+
synthetic constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
abstract forwarding-stub operator +(covariant dynamic b) → dynamic;
24+
}
25+
class D extends core::Object {
26+
synthetic constructor •() → self::D
27+
: super core::Object::•()
28+
;
29+
operator +(dynamic d) → dynamic
30+
return null;
31+
}
32+
class E extends self::D {
33+
synthetic constructor •() → self::E
34+
: super self::D::•()
35+
;
36+
forwarding-stub forwarding-semi-stub operator +(covariant core::int e) → dynamic
37+
return super.{self::D::+}(e);
38+
}
39+
static method main() → dynamic {}

pkg/front_end/testcases/text_serialization.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ fallthrough: ExpectationFileMismatch
9898
fibonacci: TextSerializationFailure # Was: Pass
9999
for_in_scope: TextSerializationFailure # Was: Pass
100100
for_in_without_declaration: TextSerializationFailure
101+
forwarding_stub_for_operator: TextSerializationFailure
101102
function_in_field: TextSerializationFailure # Was: Pass
102103
function_type_assignments: TextSerializationFailure # Was: Pass
103104
function_type_default_value: TextSerializationFailure

0 commit comments

Comments
 (0)