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

Issue 1035443002: Implement new flatten specification. (Closed)

Created:
5 years, 9 months ago by Johnni Winther
Modified:
5 years, 9 months ago
Reviewers:
karlklose, Paul Berry
CC:
reviews_dartlang.org
Target Ref:
refs/remotes/git-svn
Visibility:
Public.

Description

Implement new flatten specification. BUG=http://dartbug.com/22921 R=karlklose@google.com Committed: https://code.google.com/p/dart/source/detail?r=44659

Patch Set 1 #

Total comments: 2

Patch Set 2 : Updated cf. comment. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+126 lines, -31 lines) Patch
M pkg/compiler/lib/src/core_types.dart View 2 chunks +4 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/dart_types.dart View 1 1 chunk +31 lines, -0 lines 1 comment Download
M pkg/compiler/lib/src/typechecker.dart View 2 chunks +2 lines, -21 lines 0 comments Download
A tests/compiler/dart2js/flatten_test.dart View 1 chunk +82 lines, -0 lines 0 comments Download
M tests/compiler/dart2js/type_test_helper.dart View 2 chunks +7 lines, -1 line 0 comments Download
M tests/language/language_dart2js.status View 1 chunk +0 lines, -9 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
Johnni Winther
5 years, 9 months ago (2015-03-24 10:22:08 UTC) #2
karlklose
LGTM. https://codereview.chromium.org/1035443002/diff/1/pkg/compiler/lib/src/dart_types.dart File pkg/compiler/lib/src/dart_types.dart (right): https://codereview.chromium.org/1035443002/diff/1/pkg/compiler/lib/src/dart_types.dart#newcode1250 pkg/compiler/lib/src/dart_types.dart:1250: return futureType.typeArguments.first; You could use 'single' instead of ...
5 years, 9 months ago (2015-03-24 10:27:44 UTC) #3
Johnni Winther
https://codereview.chromium.org/1035443002/diff/1/pkg/compiler/lib/src/dart_types.dart File pkg/compiler/lib/src/dart_types.dart (right): https://codereview.chromium.org/1035443002/diff/1/pkg/compiler/lib/src/dart_types.dart#newcode1250 pkg/compiler/lib/src/dart_types.dart:1250: return futureType.typeArguments.first; On 2015/03/24 10:27:43, karlklose wrote: > You ...
5 years, 9 months ago (2015-03-24 11:24:04 UTC) #4
Johnni Winther
Committed patchset #2 (id:20001) manually as 44659 (presubmit successful).
5 years, 9 months ago (2015-03-24 11:29:07 UTC) #5
Paul Berry
5 years, 9 months ago (2015-03-25 15:22:25 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/1035443002/diff/20001/pkg/compiler/lib/src/da...
File pkg/compiler/lib/src/dart_types.dart (right):

https://codereview.chromium.org/1035443002/diff/20001/pkg/compiler/lib/src/da...
pkg/compiler/lib/src/dart_types.dart:1241: DartType flatten(DartType type) {
There are two corner cases I ran into in the analyzer implementation that don't
seem to be addressed here.  If T != Future<S> but T <: Future, it's possible for
there to be multiple type arguments to Future appearing in the class hierarchy. 
When this happens, there will either be:

1. a single type S that is at least as specific as all the others (i.e. the
"most specific" type argument to future), in which case, that should be the
result of flatten().  Or:

2. no type S that is at least as specific as all the others, in which case I
believe flatten(T) should be T.

For example, assume the following classes exist:
class Base
class Derived1 extends Base
class Derived2 extends Base
class A extends Future<Derived1> implements Future<Base>
class B extends Future<Base> implements Future<Derived1>
class C extends Future<Derived1> implements Future<Derived2>
class D extends Future<Derived2> implements Future<Derived1>

Then:
- flatten(A) = flatten(B) = Derived1, since Derived1 is more specific than Base
(case 1).
- flatten(C) = C and flatten(D) = D, since neither Derived1 nor Derived2 is more
specific than the other.

The general algorithm for finding the "most specific" type out of a set (if it
exists) turned out to be unexpectedly tricky.  You can see my implementation
around line 1855 of
https://codereview.chromium.org/1023903002/diff/1/pkg/analyzer/lib/src/genera...
(the _findMostSpecificType function).

Powered by Google App Engine
This is Rietveld 408576698