Skip to content

Commit 10a04a4

Browse files
Dmitry Stefantsovcommit-bot@chromium.org
authored andcommitted
[fasta] Fix crash when override inference depends on field inference
Change-Id: I34a273185ba09f2740783cf8a25ac6d5f754c621 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104762 Reviewed-by: Aske Simon Christensen <askesc@google.com>
1 parent 35f60f6 commit 10a04a4

9 files changed

Lines changed: 157 additions & 1 deletion

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ class ClassHierarchyNodeBuilder {
911911
debug?.log(
912912
"${cls.fullNameForErrors} -> ${bCls.fullNameForErrors} $bSubstitution");
913913
}
914-
if (bSubstitution != null) {
914+
if (bSubstitution != null && inheritedType is! ImplicitFieldType) {
915915
inheritedType = bSubstitution.substituteType(inheritedType);
916916
}
917917

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
class A<X> {
6+
final foo = "bar";
7+
}
8+
9+
class B<Y> extends A<Y> {
10+
final foo;
11+
12+
B(this.foo);
13+
}
14+
15+
main() {}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
Object.runtimeType
28+
Object._simpleInstanceOf
29+
Object._instanceOf
30+
A.foo
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+
-> A<Y>
43+
interfaces:
44+
classMembers:
45+
Object.toString
46+
Object.runtimeType
47+
Object._simpleInstanceOf
48+
Object._instanceOf
49+
B.foo
50+
Object.noSuchMethod
51+
Object._identityHashCode
52+
Object.hashCode
53+
Object._simpleInstanceOfFalse
54+
Object._simpleInstanceOfTrue
55+
Object.==
56+
classSetters:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A<X extends core::Object = dynamic> extends core::Object {
6+
final field dynamic foo = "bar";
7+
synthetic constructor •() → self::A<self::A::X>
8+
: super core::Object::•()
9+
;
10+
}
11+
class B<Y extends core::Object = dynamic> extends self::A<self::B::Y> {
12+
final field dynamic foo;
13+
constructor •(dynamic foo) → self::B<self::B::Y>
14+
: self::B::foo = foo, super self::A::•()
15+
;
16+
}
17+
static method main() → dynamic {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A<X extends core::Object = dynamic> extends core::Object {
6+
final field dynamic foo = "bar";
7+
synthetic constructor •() → self::A<self::A::X>
8+
: super core::Object::•()
9+
;
10+
}
11+
class B<Y extends core::Object = dynamic> extends self::A<self::B::Y> {
12+
final field dynamic foo;
13+
constructor •(dynamic foo) → self::B<self::B::Y>
14+
: self::B::foo = foo, super self::A::•()
15+
;
16+
}
17+
static method main() → dynamic {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A<X extends core::Object = dynamic> extends core::Object {
6+
final field dynamic foo;
7+
synthetic constructor •() → self::A<self::A::X>
8+
;
9+
}
10+
class B<Y extends core::Object = dynamic> extends self::A<self::B::Y> {
11+
final field dynamic foo;
12+
constructor •(dynamic foo) → self::B<self::B::Y>
13+
;
14+
}
15+
static method main() → dynamic
16+
;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A<X extends core::Object = dynamic> extends core::Object {
6+
final field core::String foo = "bar";
7+
synthetic constructor •() → self::A<self::A::X>
8+
: super core::Object::•()
9+
;
10+
}
11+
class B<Y extends core::Object = dynamic> extends self::A<self::B::Y> {
12+
final field core::String foo;
13+
constructor •(core::String foo) → self::B<self::B::Y>
14+
: self::B::foo = foo, super self::A::•()
15+
;
16+
}
17+
static method main() → dynamic {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A<X extends core::Object = dynamic> extends core::Object {
6+
final field core::String foo = "bar";
7+
synthetic constructor •() → self::A<self::A::X>
8+
: super core::Object::•()
9+
;
10+
}
11+
class B<Y extends core::Object = dynamic> extends self::A<self::B::Y> {
12+
final field core::String foo;
13+
constructor •(core::String foo) → self::B<self::B::Y>
14+
: self::B::foo = foo, super self::A::•()
15+
;
16+
}
17+
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
@@ -474,6 +474,7 @@ inference/null_coalescing_operator_2: TextSerializationFailure # Was: Pass
474474
inference/null_literal_should_not_infer_as_bottom: TextSerializationFailure # Was: Pass
475475
inference/overloaded_int_operators: TextSerializationFailure # Was: Pass
476476
inference/override_equals: TextSerializationFailure # Was: RuntimeError
477+
inference/override_inference_depends_on_field_inference: TextSerializationFailure
477478
inference/parameter_defaults_downwards: TextSerializationFailure # Was: Pass
478479
inference/parameter_defaults_upwards: TextSerializationFailure # Was: Pass
479480
inference/promote_bounds: TextSerializationFailure # Was: Pass

0 commit comments

Comments
 (0)