-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Implement full subtyping rules for extension types vs FutureOr
Closes #55578 Change-Id: Id344e9057f42b3fc19a6ff83ce000775aec5789a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364720 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
- Loading branch information
1 parent
5b2ea0c
commit 54c9b37
Showing
10 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
|
||
extension type E(Future<String> it) implements Future<String> {} | ||
|
||
foo(FutureOr<String> x) {} | ||
|
||
E bar() => throw 0; | ||
|
||
test() => foo(bar()); // Ok. |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/extension_types/issue55578.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library; | ||
import self as self; | ||
import "dart:async" as asy; | ||
import "dart:core" as core; | ||
|
||
import "dart:async"; | ||
|
||
extension type E(asy::Future<core::String> it) implements asy::Future<core::String> { | ||
abstract extension-type-member representation-field get it() → asy::Future<core::String>; | ||
constructor • = self::E|constructor#; | ||
constructor tearoff • = self::E|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method E|constructor#(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ { | ||
lowered final self::E /* erasure=asy::Future<core::String> */ #this = it; | ||
return #this; | ||
} | ||
static extension-type-member method E|constructor#_#new#tearOff(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
return self::E|constructor#(it); | ||
static method foo(FutureOr<core::String>x) → dynamic {} | ||
static method bar() → self::E /* erasure=asy::Future<core::String> */ | ||
return throw 0; | ||
static method test() → dynamic | ||
return self::foo(self::bar()); |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/extension_types/issue55578.dart.strong.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library; | ||
import self as self; | ||
import "dart:async" as asy; | ||
import "dart:core" as core; | ||
|
||
import "dart:async"; | ||
|
||
extension type E(asy::Future<core::String> it) implements asy::Future<core::String> { | ||
abstract extension-type-member representation-field get it() → asy::Future<core::String>; | ||
constructor • = self::E|constructor#; | ||
constructor tearoff • = self::E|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method E|constructor#(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ { | ||
lowered final self::E /* erasure=asy::Future<core::String> */ #this = it; | ||
return #this; | ||
} | ||
static extension-type-member method E|constructor#_#new#tearOff(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
return self::E|constructor#(it); | ||
static method foo(FutureOr<core::String>x) → dynamic {} | ||
static method bar() → self::E /* erasure=asy::Future<core::String> */ | ||
return throw 0; | ||
static method test() → dynamic | ||
return self::foo(self::bar()); |
9 changes: 9 additions & 0 deletions
9
pkg/front_end/testcases/extension_types/issue55578.dart.textual_outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'dart:async'; | ||
|
||
extension type E(Future<String> it) implements Future<String> {} | ||
|
||
foo(FutureOr<String> x) {} | ||
|
||
E bar() => throw 0; | ||
|
||
test() => foo(bar()); |
9 changes: 9 additions & 0 deletions
9
pkg/front_end/testcases/extension_types/issue55578.dart.textual_outline_modelled.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'dart:async'; | ||
|
||
E bar() => throw 0; | ||
|
||
extension type E(Future<String> it) implements Future<String> {} | ||
|
||
foo(FutureOr<String> x) {} | ||
|
||
test() => foo(bar()); |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/extension_types/issue55578.dart.weak.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library; | ||
import self as self; | ||
import "dart:async" as asy; | ||
import "dart:core" as core; | ||
|
||
import "dart:async"; | ||
|
||
extension type E(asy::Future<core::String> it) implements asy::Future<core::String> { | ||
abstract extension-type-member representation-field get it() → asy::Future<core::String>; | ||
constructor • = self::E|constructor#; | ||
constructor tearoff • = self::E|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method E|constructor#(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ { | ||
lowered final self::E /* erasure=asy::Future<core::String> */ #this = it; | ||
return #this; | ||
} | ||
static extension-type-member method E|constructor#_#new#tearOff(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
return self::E|constructor#(it); | ||
static method foo(FutureOr<core::String>x) → dynamic {} | ||
static method bar() → self::E /* erasure=asy::Future<core::String> */ | ||
return throw 0; | ||
static method test() → dynamic | ||
return self::foo(self::bar()); |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/extension_types/issue55578.dart.weak.modular.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library; | ||
import self as self; | ||
import "dart:async" as asy; | ||
import "dart:core" as core; | ||
|
||
import "dart:async"; | ||
|
||
extension type E(asy::Future<core::String> it) implements asy::Future<core::String> { | ||
abstract extension-type-member representation-field get it() → asy::Future<core::String>; | ||
constructor • = self::E|constructor#; | ||
constructor tearoff • = self::E|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method E|constructor#(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ { | ||
lowered final self::E /* erasure=asy::Future<core::String> */ #this = it; | ||
return #this; | ||
} | ||
static extension-type-member method E|constructor#_#new#tearOff(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
return self::E|constructor#(it); | ||
static method foo(FutureOr<core::String>x) → dynamic {} | ||
static method bar() → self::E /* erasure=asy::Future<core::String> */ | ||
return throw 0; | ||
static method test() → dynamic | ||
return self::foo(self::bar()); |
22 changes: 22 additions & 0 deletions
22
pkg/front_end/testcases/extension_types/issue55578.dart.weak.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
library; | ||
import self as self; | ||
import "dart:async" as asy; | ||
import "dart:core" as core; | ||
|
||
import "dart:async"; | ||
|
||
extension type E(asy::Future<core::String> it) implements asy::Future<core::String> { | ||
abstract extension-type-member representation-field get it() → asy::Future<core::String>; | ||
constructor • = self::E|constructor#; | ||
constructor tearoff • = self::E|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method E|constructor#(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
; | ||
static extension-type-member method E|constructor#_#new#tearOff(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
return self::E|constructor#(it); | ||
static method foo(FutureOr<core::String>x) → dynamic | ||
; | ||
static method bar() → self::E /* erasure=asy::Future<core::String> */ | ||
; | ||
static method test() → dynamic | ||
; |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/extension_types/issue55578.dart.weak.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library; | ||
import self as self; | ||
import "dart:async" as asy; | ||
import "dart:core" as core; | ||
|
||
import "dart:async"; | ||
|
||
extension type E(asy::Future<core::String> it) implements asy::Future<core::String> { | ||
abstract extension-type-member representation-field get it() → asy::Future<core::String>; | ||
constructor • = self::E|constructor#; | ||
constructor tearoff • = self::E|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method E|constructor#(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ { | ||
lowered final self::E /* erasure=asy::Future<core::String> */ #this = it; | ||
return #this; | ||
} | ||
static extension-type-member method E|constructor#_#new#tearOff(asy::Future<core::String> it) → self::E /* erasure=asy::Future<core::String> */ | ||
return self::E|constructor#(it); | ||
static method foo(FutureOr<core::String>x) → dynamic {} | ||
static method bar() → self::E /* erasure=asy::Future<core::String> */ | ||
return throw 0; | ||
static method test() → dynamic | ||
return self::foo(self::bar()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters