Skip to content

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

Closed
a-siva opened this issue Feb 3, 2012 · 3 comments
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue web-dart2js

Comments

@a-siva
Copy link
Contributor

a-siva commented Feb 3, 2012

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();
}

@iposva-google
Copy link
Contributor

Added Area-Frog, Triaged labels.

@anders-sandholm
Copy link
Contributor

Removed Area-Frog label.
Added Area-Dart2JS, FromAreaFrog labels.

@kasperl
Copy link

kasperl commented Jun 12, 2012

Added WontFix label.

@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue and removed resolution-wont_fix labels Mar 1, 2016
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
closed-not-planned Closed as we don't intend to take action on the reported issue web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants