-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ThirdTest reports compilation error "static members cannot hide parent members" incorrectly #1511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Removed Area-Frog label. |
Added WontFix label. |
copybara-service bot
pushed a commit
that referenced
this issue
Sep 22, 2021
We use an extension getter instead of an instance getter because it doesn't conflict with any potential existing or future enums which want an element named `name`. Keeping the namespace for enum elements open is a priority. We currently only reserve `index` and `values`. BUG: dart-lang/language#1511 Fixes language issue #1511, which is a long-standing request, and should replace a number of alternative implementations which are based on parsing the `toString()`. This version has two fields on the shared superclass, the index and private name, and has a separate `toString` for each `enum` class which hard-codes that enum's class name. An earlier version had both `"name"` and `"ClassName.name"` as fields to be able to reuse the same `toString` method on all enum classes, but that cost too much for JS compiled code. Even having just `ClassName.` as a field and then combining inside `toString` requires more code to create the enum instances. Instead this version hardcodes the `ClassName.` string once in the `toString` method, which means each enum class has its own toString (which can *potentially* be tree-shaken then.) This still tree-shakes slightly worse than the previous implementation where every enum class had its own `index` and `_name` fields independent of each other, which could then be tree-shaken independently. However, the `index` was already made an interface member with the addition of the `Enum` interface, so code which accesses `.index` on something of the `Enum` supertype could prevent tree-shaking of all enum classes' `index` fields. Likewise any general access to the "name" of an enum would necessarily do the same for the name. This CL makes up for some of that by sharing more implementation between enum classes. DartVM AOT CodeSize impact: ~0.15% regression on gallery (little less on big g3 app) TEST= New tests added to enum_test.dart Change-Id: Id25334e6c987f470f558de3c141d0e3ff542b020 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210480 Commit-Queue: Lasse R.H. Nielsen <[email protected]> Reviewed-by: Stephen Adams <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
sivamach[frog]>out/Release_ia32/frog/bin/frog ../tests/language/src/ThirdTest.dart
../tests/language/src/ThirdTest.dart:8:3: error: static members cannot hide parent members
static var s;
^^^^^^^^^^^^^
../tests/language/src/ThirdTest.dart:24:3: error: static members cannot hide parent members
static var s;
^^^^^^^^^^^^^
../tests/language/src/ThirdTest.dart:10:3: error: static members cannot hide parent members
static foo() {
^^^^^^^^^^^^^^^
../tests/language/src/ThirdTest.dart:26:3: error: static members cannot hide parent members
static foo(x) {
^^^^^^^^^^^^^^^^
compilation failed with 2 errors
Compilation failed
Contents of ThirdTest.dart:
// Copyright (c) 2011, 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.
// Third dart test program.
class A extends B {
var a;
static var s;
static foo() {
return s;
}
A(x, y) : super(y), a = x { }
value() {
return a + b + foo();
}
}
class B {
var b;
static var s;
static foo(x) {
return x + s;
}
value() {
return b + foo(s) + A.foo();
}
B(x) : b = x {
b = b + 1;
}
}
class ThirdTest {
static testMain() {
var a = new A(1, 2);
var b = new B(3);
A.s = 4;
B.s = 5;
Expect.equals(26, a.value() + b.value());
}
}
main() {
ThirdTest.testMain();
}
The text was updated successfully, but these errors were encountered: