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

Issue 12210013: Implement subtype for type variables. (Closed)

Created:
7 years, 10 months ago by Johnni Winther
Modified:
7 years, 8 months ago
Reviewers:
karlklose
CC:
reviews_dartlang.org, ahe
Visibility:
Public.

Description

Implement subtype for type variables.

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+107 lines, -10 lines) Patch
M sdk/lib/_internal/compiler/implementation/dart_types.dart View 2 chunks +5 lines, -2 lines 3 comments Download
M sdk/lib/_internal/compiler/implementation/elements/elements.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/elements/modelx.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart View 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/resolution/members.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M tests/compiler/dart2js/subtype_test.dart View 2 chunks +94 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Johnni Winther
7 years, 10 months ago (2013-02-05 14:58:24 UTC) #1
ahe
DBC https://codereview.chromium.org/12210013/diff/1/sdk/lib/_internal/compiler/implementation/dart_types.dart File sdk/lib/_internal/compiler/implementation/dart_types.dart (right): https://codereview.chromium.org/12210013/diff/1/sdk/lib/_internal/compiler/implementation/dart_types.dart#newcode795 sdk/lib/_internal/compiler/implementation/dart_types.dart:795: return isSubtype(typeVariable.upperBound, s); How do you deal with: ...
7 years, 10 months ago (2013-02-05 15:14:40 UTC) #2
Johnni Winther
https://codereview.chromium.org/12210013/diff/1/sdk/lib/_internal/compiler/implementation/dart_types.dart File sdk/lib/_internal/compiler/implementation/dart_types.dart (right): https://codereview.chromium.org/12210013/diff/1/sdk/lib/_internal/compiler/implementation/dart_types.dart#newcode795 sdk/lib/_internal/compiler/implementation/dart_types.dart:795: return isSubtype(typeVariable.upperBound, s); On 2013/02/05 15:14:40, ahe wrote: > ...
7 years, 10 months ago (2013-02-05 18:45:57 UTC) #3
Johnni Winther
Ping
7 years, 10 months ago (2013-02-18 07:52:26 UTC) #4
ahe
7 years, 10 months ago (2013-02-18 08:22:18 UTC) #5
DBC

https://codereview.chromium.org/12210013/diff/1/sdk/lib/_internal/compiler/im...
File sdk/lib/_internal/compiler/implementation/dart_types.dart (right):

https://codereview.chromium.org/12210013/diff/1/sdk/lib/_internal/compiler/im...
sdk/lib/_internal/compiler/implementation/dart_types.dart:795: return
isSubtype(typeVariable.upperBound, s);
On 2013/02/05 18:45:57, Johnni Winther wrote:
> On 2013/02/05 15:14:40, ahe wrote:
> > How do you deal with:
> > 
> > class Foo<T extends S, S extends T> {
> >   haveFun(T t, S s) {
> >     t = s;
> >     s = t;
> >   }
> > }
> 
> I don't. I think this should be part of the (still unimplemented) check on
> bounds.

I don't like having known unbounded recursion in a type checker. I think this
would be really simple to implement using a variant of asInstanceOf. This method
can keep looking for an upper bound as long as it isn't a type variable or
itself.

Powered by Google App Engine
This is Rietveld 408576698