Skip to content

Commit a8a9171

Browse files
Avoid crashing on this property access
Fixes #35875 Change-Id: I5ae2f73cd792aae165e787d7856b0af9a7c2e19e Reviewed-on: https://dart-review.googlesource.com/c/92282 Commit-Queue: Peter von der Ahé <[email protected]> Commit-Queue: Kevin Millikin <[email protected]> Auto-Submit: Peter von der Ahé <[email protected]> Reviewed-by: Kevin Millikin <[email protected]>
1 parent 33bc628 commit a8a9171

9 files changed

+114
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ abstract class PropertyAccessGenerator implements Generator {
296296
Member setter,
297297
bool isNullAware) {
298298
if (helper.forest.isThisExpression(receiver)) {
299-
return unsupported("ThisExpression", offsetForToken(token), helper.uri);
299+
getter ??= helper.lookupInstanceMember(name);
300+
setter ??= helper.lookupInstanceMember(name, isSetter: true);
301+
return new ThisPropertyAccessGenerator(
302+
helper, token, name, getter, setter);
300303
} else {
301304
return isNullAware
302305
? new NullAwarePropertyAccessGenerator(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 {
6+
int a;
7+
A(int a) {
8+
(this).a = a;
9+
}
10+
}
11+
12+
main() {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
A.a
27+
Object.toString
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+
A.a
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
field core::int a = null;
7+
constructor •(core::int a) → self::A
8+
: super core::Object::•() {
9+
this.{self::A::a} = a;
10+
}
11+
}
12+
static method main() → dynamic {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
field core::int a = null;
7+
constructor •(core::int a) → self::A
8+
: super core::Object::•() {
9+
this.{self::A::a} = a;
10+
}
11+
}
12+
static method main() → dynamic {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
field core::int a;
7+
constructor •(core::int a) → self::A
8+
;
9+
}
10+
static method main() → dynamic
11+
;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
field core::int a = null;
7+
constructor •(core::int a) → self::A
8+
: super core::Object::•() {
9+
this.{self::A::a} = a;
10+
}
11+
}
12+
static method main() → dynamic {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class A extends core::Object {
6+
field core::int a = null;
7+
constructor •(core::int a) → self::A
8+
: super core::Object::•() {
9+
this.{self::A::a} = a;
10+
}
11+
}
12+
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
@@ -667,6 +667,7 @@ invalid_type: TypeCheckError
667667
invocations: TextSerializationFailure # Was: RuntimeError
668668
issue34515: TextSerializationFailure
669669
issue34899: TypeCheckError
670+
issue35875: TextSerializationFailure
670671
literals: TextSerializationFailure # Was: Pass
671672
local_generic_function: TextSerializationFailure # Was: Pass
672673
magic_const: TextSerializationFailure # Was: Pass

0 commit comments

Comments
 (0)