Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Issue 1143003007: Fix handling of nested typedefs (for real this time). (Closed)

Created:
5 years, 6 months ago by Paul Berry
Modified:
5 years, 6 months ago
Reviewers:
Brian Wilkerson
CC:
reviews_dartlang.org
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Fix handling of nested typedefs (for real this time). This is a re-fix of dartbug.com/21912, which I previously fixed incorrectly. Previously, our approach to avoiding infinite loops when comparing types was to maintain a set of typedefs being expanded on the stack, and prune the comparison whenever an attempt was made to expand a typedef that was already being expanded. However, this was too strict, since there are legal (non-circular) types which invole expanding a given typedef in reentrant fashion; we can't prune these types without producing incorrect semantics. An example (from the bug report) is the type of f in the code below: typedef T Function2<S, T>(S z); Function2<Function2<A, B>, Function2<B, A>> f; The solution is to maintain the list of typedefs being expanded inside each FunctionTypeImpl object (and InterfaceTypeImpl object) rather than on the stack during the comparison; this allows us to distinguish the situations where we need to prune (those having to do exclusively with expansion of a typedef) from the situations where we shouldn't prune (those having to do with substitution of a type parameter). A beneficial side effect of this change is that code that interacts with types no longer needs to worry about typedef circularities, since the circularities will automatically be pruned while exploring the type definitions. This simplifies the implementation of isAssignableTo, isSubtypeOf, operator==, and hashCode. (Note, however, that code still needs to cope with circularities in the inheritance hierarchy). BUG=dartbug.com/21912 R=brianwilkerson@google.com Committed: https://github.com/dart-lang/sdk/commit/62f7ac8c5db16a22ac901f8639a80b532d230376

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+728 lines, -510 lines) Patch
M pkg/analyzer/lib/src/generated/element.dart View 45 chunks +474 lines, -505 lines 0 comments Download
M pkg/analyzer/lib/src/generated/testing/element_factory.dart View 3 chunks +12 lines, -1 line 0 comments Download
M pkg/analyzer/test/generated/element_test.dart View 4 chunks +177 lines, -2 lines 0 comments Download
M pkg/analyzer/test/generated/non_error_resolver_test.dart View 1 chunk +34 lines, -0 lines 0 comments Download
M pkg/analyzer/test/generated/static_type_warning_code_test.dart View 1 chunk +29 lines, -0 lines 0 comments Download
M tests/language/regress_21912_test.dart View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 4 (1 generated)
Paul Berry
5 years, 6 months ago (2015-06-01 18:08:51 UTC) #2
Brian Wilkerson
LGTM
5 years, 6 months ago (2015-06-01 19:00:40 UTC) #3
Paul Berry
5 years, 6 months ago (2015-06-01 19:45:33 UTC) #4
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
62f7ac8c5db16a22ac901f8639a80b532d230376 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698