-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Type variables are not in scope of static methods #643
Comments
This comment was originally written by [email protected] Just to make sure I understand, the issue is that T is both a type variable and a top level class. We shouldn't warn about T inside of m() as a type variable because it isn't in scope, and instead should keep looking up the scope tree to resolve the symbol. |
This comment was originally written by [email protected] Set owner to [email protected]. |
Sorry I should have given more details. It is not obvious what I consider a problem here. The only thing I think is wrong with the errors from dartc is that there are two. One error message should be sufficient. |
Sorry, I was wrong. The spec says that the type variable isn't in scope. I think a warning would be nice, though. |
This comment was originally written by [email protected] Review for dartc up at http://codereview.chromium.org/9250017/ The following code now runs to completion, printing one warning (already added by Konstantin last week) $ cat /tmp/fish.dart class Foo<T> { main() { $ dartc_test /tmp/fish.dart If you rename class T to another name, you get: $ dartc_test /tmp/fish.dart |
This comment was originally written by [email protected] r3434 Added Fixed label. |
Reopened since the corresponding test, after re-enabled, currently fails on the VM, dart2js and dartc. cc @peter-ahe-google. |
I added the following line to the language.status and language_dart2js.status files: +type_variable_shadows_class_test: Fail # Issue #643 |
This is working on all platform. The test is invalid since the expected behavior has changed. There is already a negative test for the correct behavior (tests/language/type_variable_static_context_negative_test.dart) https://code.google.com/p/dart/source/detail?r=15247 Added Fixed label. |
…ions) https://dart.googlesource.com/protobuf/+log/408f69b98b2d..3105588b8e51 2022-06-15 [email protected] Remove unused function 2022-06-15 [email protected] Simplify PbList implementation, fix freezing (#626) 2022-06-15 [email protected] Remove frozen message modification handling (#643) 2022-06-15 [email protected] Bump version number for development, add changelog entry for #644 2022-06-15 [email protected] Remove ReadonlyMessageMixin (#644) 2022-06-15 [email protected] Release protobuf-2.1.0, protoc_plugin-20.0.1 (#677) 2022-06-14 [email protected] Specify `GeneratedMessage operator==` argument type (#675) 2022-06-14 [email protected] Add changes since the last protobuf release to CHANGELOG (#619) 2022-06-10 [email protected] Tweak consts.dart docs (#674) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/dart-protobuf-dart-sdk Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Dart Protobuf Support: https://github.com/dart-lang/protobuf/issues To file a bug in Dart SDK: https://github.com/dart-lang/sdk/issues To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Tbr: [email protected] Change-Id: If0f2beb1f63ef9a7527abaa116d883ef0fd4b6c9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248620 Commit-Queue: Nate Bosch <[email protected]> Reviewed-by: Nate Bosch <[email protected]>
$ cat fisk.dart
class T {
toString() => "class T";
}
class Foo<T> {
static m() => new T();
}
main() {
print(Foo.m());
}
$ dartc_test fisk.dart
fisk.dart:6: cannot access type variable T in static context
5: class Foo<T> {
6: static m() => new T();
fisk.dart:6: New expression does not resolve to a constructor
5: class Foo<T> {
6: static m() => new T();
Compilation failed with 2 problems.
$ frogsh fisk.dart
We are sorry, but... no constructors on type parameters yet
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
CompilerException: We are sorry, but... no constructors on type parameters yet
at World._message (frogsh:23264:5)
at World.internalError (frogsh:23287:8)
at ParameterType.getConstructor (frogsh:21501:18)
at ParameterType.getConstructor$1 (frogsh:21525:15)
at MethodGenerator.visitNewExpression (frogsh:14264:16)
at lang_NewExpression.visit (frogsh:20744:18)
at MethodGenerator.visitValue (frogsh:13523:20)
at MethodGenerator.visitTypedValue (frogsh:13528:15)
at MethodGenerator.visitReturnStatement (frogsh:13601:22)
at ReturnStatement.visit (frogsh:20362:18)
$ dart fisk.dart
class T
The text was updated successfully, but these errors were encountered: