forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Special error message for illegal override of a setter by a field
This situation would produce an error referring to the erroneous type as a return type instead of a paremeter/field type. Change-Id: Ida72b0b85b448e3a05cadf38511e7e32d19986f1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115702 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Aske Simon Christensen <askesc@google.com>
- Loading branch information
Showing
12 changed files
with
145 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
pkg/front_end/testcases/general/override_setter_with_field.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2019, 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. | ||
|
||
abstract class A { | ||
void set x(Object y); | ||
} | ||
|
||
class B implements A { | ||
int x; | ||
} | ||
|
||
main() { | ||
new B().x = 5; | ||
} |
27 changes: 27 additions & 0 deletions
27
pkg/front_end/testcases/general/override_setter_with_field.dart.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/general/override_setter_with_field.dart:10:7: Error: The field 'B.x' has type 'int', which does not match the corresponding type, 'Object', in the overridden setter, 'A.x'. | ||
// - 'Object' is from 'dart:core'. | ||
// int x; | ||
// ^ | ||
// pkg/front_end/testcases/general/override_setter_with_field.dart:6:12: Context: This is the overridden method ('x'). | ||
// void set x(Object y); | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class A extends core::Object { | ||
synthetic constructor •() → self::A* | ||
; | ||
abstract set x(core::Object* y) → void; | ||
} | ||
class B extends core::Object implements self::A { | ||
field core::int* x; | ||
synthetic constructor •() → self::B* | ||
; | ||
} | ||
static method main() → dynamic | ||
; |
30 changes: 30 additions & 0 deletions
30
pkg/front_end/testcases/general/override_setter_with_field.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/general/override_setter_with_field.dart:10:7: Error: The field 'B.x' has type 'int', which does not match the corresponding type, 'Object', in the overridden setter, 'A.x'. | ||
// - 'Object' is from 'dart:core'. | ||
// int x; | ||
// ^ | ||
// pkg/front_end/testcases/general/override_setter_with_field.dart:6:12: Context: This is the overridden method ('x'). | ||
// void set x(Object y); | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class A extends core::Object { | ||
synthetic constructor •() → self::A* | ||
: super core::Object::•() | ||
; | ||
abstract set x(core::Object* y) → void; | ||
} | ||
class B extends core::Object implements self::A { | ||
field core::int* x = null; | ||
synthetic constructor •() → self::B* | ||
: super core::Object::•() | ||
; | ||
} | ||
static method main() → dynamic { | ||
new self::B::•().{self::B::x} = 5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters