Skip to content
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

Imprecise type analysis of window.document.elements #380

Closed
stevemessick opened this issue Nov 8, 2011 · 7 comments
Closed

Imprecise type analysis of window.document.elements #380

stevemessick opened this issue Nov 8, 2011 · 7 comments

Comments

@stevemessick
Copy link
Contributor

This is in dom:html, the definition of class Document (actually, the interface Element that it inherits from). The problem appears to be that the field elements has dynamic type even though the getter is defined as ElementList.

Since the type of window.document.elements is dynamic, code completion can offer no proposals, which surprised users (in a negative way).

TypeAnalyzer should return ElementList for the type of window.document.elements.

@stevemessick
Copy link
Contributor Author

Has anyone had a chance to look at this issue yet?


Set owner to [email protected].

@DartBot
Copy link

DartBot commented Jan 31, 2012

This comment was originally written by [email protected]


The plot thickens:

#import('dart:html');

main() {
  bool isElementList = window.document.elements is ElementList;
  print ("isElementList=${isElementList}");
}

causes the compiler to run out of stack:

$ dartc_test /tmp/t.dart
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3057)
    at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:117)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:407)
    at java.lang.StringBuffer.append(StringBuffer.java:241)
    at java.io.StringWriter.write(StringWriter.java:101)
    at java.io.StringWriter.append(StringWriter.java:181)
    at java.io.StringWriter.append(StringWriter.java:41)
    at com.google.dart.compiler.backend.js.JavascriptBackend$CountingAppendable.append(JavascriptBackend.java:69)
    at com.google.common.io.CharStreams.copy(CharStreams.java:207)
    at com.google.dart.compiler.backend.js.JavascriptBackend$DepsWritingCallback.visitPart(JavascriptBackend.java:124)
    at com.google.dart.compiler.backend.js.AbstractJsBackend$DependencyBuilder.writePart(AbstractJsBackend.java:314)
    at com.google.dart.compiler.backend.js.AbstractJsBackend$DependencyBuilder.writeParts(AbstractJsBackend.java:292)
    at com.google.dart.compiler.backend.js.AbstractJsBackend$DependencyBuilder.build(AbstractJsBackend.java:128)
    at com.google.dart.compiler.backend.js.JavascriptBackend.packageLibs(JavascriptBackend.java:149)
    at com.google.dart.compiler.backend.js.JavascriptBackend.packageApp(JavascriptBackend.java:175)
    at com.google.dart.compiler.DartCompiler$Compiler.packageApp(DartCompiler.java:797)
    at com.google.dart.compiler.DartCompiler$Compiler.compile(DartCompiler.java:183)
    at com.google.dart.compiler.DartCompiler$Compiler.access$200(DartCompiler.java:122)
    at com.google.dart.compiler.DartCompiler.compileLib(DartCompiler.java:1148)
    at com.google.dart.runner.DartRunner.compileApp(DartRunner.java:308)
    at com.google.dart.runner.DartRunner.compileApp(DartRunner.java:296)
    at com.google.dart.runner.DartRunner.throwingMain(DartRunner.java:130)
    at com.google.dart.runner.DartRunner.main(DartRunner.java:98)

@stevemessick
Copy link
Contributor Author

Thanks for taking a look.

This is the same problem seen in 1398. Please see the detailed analysis there.

From Element.dart:
  ElementList get elements();

  // TODO: The type of value should be Collection<Element>. See http://b/5392897
  void set elements(value);

@DartBot
Copy link

DartBot commented Feb 2, 2012

This comment was originally written by [email protected]


The underlying problem is there is no type on this getter/setter. Apparently dartc chokec when the setter and getter did not have the same type, but that is no longer the case.

https://chromiumcodereview.appspot.com/9315061/

Once we get the updated library integrated, let me know if the problem persists.


Set owner to [email protected].

@DartBot
Copy link

DartBot commented Feb 2, 2012

This comment was originally written by [email protected]


The problem persists: ref b/5392897

class Test<E> {
 Collection<E> _value;
 Set<E> get bar() { return _value; }
 void set bar( Collection<E> value) { _value =value; }
}

main() {
  Test<int> f = new Test<int>();
  f.bar().contains(3);
  f.bar.contains(3);
}

file:/tmp/foo2.dart:9: Use assignment to set field "bar" in Test<int>
     8: Test<int> f = new Test<int>();
     9: f.bar().contains(3);
file:/tmp/foo2.dart:10: Collection<int> has no method named "contains"
     9: f.bar().contains(3);
    10: f.bar.contains(3);

@stevemessick
Copy link
Contributor Author

Marked this as blocking #1531.

@DartBot
Copy link

DartBot commented Mar 8, 2012

This comment was originally written by [email protected]


Updated patch at https://chromiumcodereview.appspot.com/9315061/
Committed at r5136.


Added Fixed label.

dart-bot pushed a commit that referenced this issue Jun 12, 2019
2019-06-11 [email protected] More fixes to cast response to Stream<List<int>> (#385)
2019-06-11 [email protected] Pass Uint8List to Datagram (#382)
2019-06-11 [email protected] Cast HttpRequest and HttpClientResponse streams to List<int> (#384)
2019-06-10 [email protected] Fixes #364. Change expected result to null for default values of clientMaxWindowBits and serverMaxWindowBits
2019-06-07 [email protected] Fixes #380. Added tests for logical and bitwise operations via type aliases
2019-06-07 [email protected] Additional fix for #373. Code style improved and more strict pattern checking
2019-06-06 [email protected] Fix for #380. Added tests for type aliases for built-in types. Test string concatenation and arithmetic operations
2019-06-05 [email protected] Fixes #380. Added tests for type aliases for built-in types initialization
2019-06-05 [email protected] Fixes #373. Expect reasonable file mode on Unix
2019-06-04 [email protected] Fixes #379. Numerous fixes for io/Process tests
2019-06-04 [email protected] Fixes #378. Use Platform.resolvedExecutable instead of 'dart' command
2019-06-04 [email protected] Fixed Issue #375: it's possible that IPv6 loopback does not exist.
2019-06-04 [email protected] Fixed Issue #236: host.host can be either "localhost" or Platform.localHostname.
2019-06-04 [email protected] Issue #370, instantiate-to-bounds: added static tests for non-function type aliases.
2019-06-04 [email protected] Fix for #377. Use correct network interface type name (IPvX)
2019-06-04 [email protected] Fixes #374. Change pattern for error messages
2019-06-04 [email protected] Issue #370, instantiate-to-bounds: added dynamic tests for non-function type aliases.
2019-06-04 [email protected] Fix for #372. Expect.fail() on timeout added
2019-06-04 [email protected] Fixes #371. Remove excessive asyncStart()
2019-06-03 [email protected] Issue #147, test super bounded types: added tests for non-function type aliases.
2019-05-30 [email protected] Fixes #369. Use correct type arguments to avoid errors
2019-05-30 [email protected] Fixes #368. Don't try to bind system port
2019-05-30 [email protected] Fixes #367. Remove excessive asyncStart()
2019-05-30 [email protected] Fixes #366. Change expected result to SocketException

[email protected]

Change-Id: I137689755907b3333e597d7d210db2b4d37d70d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105641
Reviewed-by: Alexander Thomas <[email protected]>
Reviewed-by: William Hesse <[email protected]>
copybara-service bot pushed a commit that referenced this issue Sep 21, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

ecosystem (https://github.com/dart-lang/ecosystem/compare/ed39318..dcf5c4f):
  dcf5c4f  2023-09-20  Parker Lougheed  Simplify dart_flutter_team_lints install instructions (#172)

http (https://github.com/dart-lang/http/compare/decefa6..1251619):
  1251619  2023-09-19  Brian Quinlan  Add the ability to control the URL cache. (#1020)

mockito (https://github.com/dart-lang/mockito/compare/412c0be..097e563):
  097e563  2023-09-19  Ilya Yanok  Add a missing dummy `bool` value

shelf (https://github.com/dart-lang/shelf/compare/e2a02b7..4851978):
  4851978  2023-09-20  Kevin Moore  shelf_router_generator: prepare to release v1.1.0 (#380)

test (https://github.com/dart-lang/test/compare/6449495..8191a35):
  8191a355  2023-09-20  Nate Bosch  Drop a TODO about running browser after compile (#2094)
  d8e9d87d  2023-09-18  Nate Bosch  Add a silent reporter (#2093)

tools (https://github.com/dart-lang/tools/compare/70d778d..3c248df):
  3c248df  2023-09-21  Devon Carew  misc infra updates for dart-lang/tools (#165)

Change-Id: I436a34847db75f45a20b8c18996419f88214485f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327280
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Konstantin Shcheglov <[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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants