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

Issue 1663353002: Refactor strong mode's function type isSubtypeOf() to use the same structural walking code as spec … (Closed)

Created:
4 years, 10 months ago by Bob Nystrom
Modified:
4 years, 10 months ago
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Refactor strong mode's function type isSubtypeOf() to use the same structural walking code as spec mode function types. R=jmesserly@google.com, paulberry@google.com Committed: https://github.com/dart-lang/sdk/commit/6c3cf3e02c254bf487d8a395e1b902b890903cb8

Patch Set 1 #

Total comments: 2

Patch Set 2 : Remove unneeded typedef. #

Total comments: 6

Patch Set 3 : Revise. #

Patch Set 4 : Merge. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+64 lines, -101 lines) Patch
M pkg/analyzer/lib/src/dart/element/type.dart View 1 2 3 chunks +57 lines, -24 lines 0 comments Download
M pkg/analyzer/lib/src/generated/type_system.dart View 1 3 chunks +7 lines, -77 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
Bob Nystrom
Apparently there were *three* copies of the same "line up the parameters for two function ...
4 years, 10 months ago (2016-02-04 00:59:32 UTC) #2
Paul Berry
lgtm https://codereview.chromium.org/1663353002/diff/20001/pkg/analyzer/lib/src/dart/element/type.dart File pkg/analyzer/lib/src/dart/element/type.dart (right): https://codereview.chromium.org/1663353002/diff/20001/pkg/analyzer/lib/src/dart/element/type.dart#newcode728 pkg/analyzer/lib/src/dart/element/type.dart:728: bool relation = _trivialFunctionRelation(type); Nit: consider rewriting to: ...
4 years, 10 months ago (2016-02-04 13:15:43 UTC) #3
Jennifer Messerly
+1 to Paul's comments. but LGTM. I have a refactoring I will send to you ...
4 years, 10 months ago (2016-02-04 17:55:45 UTC) #4
Bob Nystrom
Committed patchset #4 (id:60001) manually as 6c3cf3e02c254bf487d8a395e1b902b890903cb8 (presubmit successful).
4 years, 10 months ago (2016-02-04 21:30:18 UTC) #6
Bob Nystrom
4 years, 10 months ago (2016-02-04 21:30:34 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/1663353002/diff/1/pkg/analyzer/lib/src/genera...
File pkg/analyzer/lib/src/generated/type_system.dart (right):

https://codereview.chromium.org/1663353002/diff/1/pkg/analyzer/lib/src/genera...
pkg/analyzer/lib/src/generated/type_system.dart:332: return
FunctionTypeImpl.structuralCompare(
On 2016/02/04 17:55:45, John Messerly wrote:
> Lovely!

:D

https://codereview.chromium.org/1663353002/diff/20001/pkg/analyzer/lib/src/da...
File pkg/analyzer/lib/src/dart/element/type.dart (right):

https://codereview.chromium.org/1663353002/diff/20001/pkg/analyzer/lib/src/da...
pkg/analyzer/lib/src/dart/element/type.dart:728: bool relation =
_trivialFunctionRelation(type);
On 2016/02/04 13:15:43, Paul Berry wrote:
> Nit: consider rewriting to:
> 
>     return _trivialFunctionRelation(type) ??
>         structuralCompare(this, type,
>             (TypeImpl t, TypeImpl s) => t.isMoreSpecificThan(s, withDyanmic));
> 
> Your call though.

I actually find that a little harder to read since it's a pretty big expression
and "??" isn't that common. I do see the merit in not needing to waste three
lines on a simple early exit return, but I think it's clearer to me that way.

https://codereview.chromium.org/1663353002/diff/20001/pkg/analyzer/lib/src/da...
pkg/analyzer/lib/src/dart/element/type.dart:739: bool relation =
_trivialFunctionRelation(type);
On 2016/02/04 13:15:43, Paul Berry wrote:
> Similar comment here.

Ack. (Though added {} for if.)

https://codereview.chromium.org/1663353002/diff/20001/pkg/analyzer/lib/src/da...
pkg/analyzer/lib/src/dart/element/type.dart:786: if (returnRelation == null)
returnRelation = parameterRelation;
On 2016/02/04 13:15:43, Paul Berry wrote:
> Analyzer style is to use braces for all "if" statements, and no one-liners, so
> this should be:
> 
>     if (returnRelation == null) {
>       returnRelation = parameterRelation;
>     }

Oops, sorry, yes. Hard to switch out an old habit.

> 
> However, my personal preference would be to do this:
> 
>     returnRelation ??= parameterRelation;
> 
> Your call between those two alternatives.

Done.

Powered by Google App Engine
This is Rietveld 408576698