-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Class type parameters wildcards are non-binding.
Wildcard type parameters are not added to the scope of the class. They do not collide with other wildcards or other wildcard type parameters. Bug: #55655 Change-Id: I473a5023c570623fe2a11df5c07d491082bab642 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371943 Commit-Queue: Kallen Tu <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Reviewed-by: Chloe Stefantsova <[email protected]>
- Loading branch information
Showing
11 changed files
with
279 additions
and
4 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
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
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
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
27 changes: 27 additions & 0 deletions
27
pkg/front_end/testcases/wildcard_variables/class_type_parameters.dart
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,27 @@ | ||
// 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. | ||
|
||
typedef _ = BB; | ||
|
||
class AA {} | ||
|
||
class BB extends AA {} | ||
|
||
class A<T, U extends AA> {} | ||
|
||
class B<_, _ extends AA> extends A<_, _> { | ||
int foo<_ extends _>([int _ = 2]) => 1; | ||
} | ||
|
||
class C<T, _ extends _> extends A<T, _> { | ||
static const int _ = 1; | ||
} | ||
|
||
class D<_, _> {} | ||
|
||
class DoesNotUseTypeVariable<_> { | ||
Type returnsBB() { | ||
return _; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
pkg/front_end/testcases/wildcard_variables/class_type_parameters.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,52 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
typedef _ = self::BB; | ||
class AA extends core::Object { | ||
synthetic constructor •() → self::AA | ||
: super core::Object::•() | ||
; | ||
} | ||
class BB extends self::AA { | ||
synthetic constructor •() → self::BB | ||
: super self::AA::•() | ||
; | ||
} | ||
class A<T extends core::Object? = dynamic, U extends self::AA> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::T%, self::A::U> | ||
: super core::Object::•() | ||
; | ||
} | ||
class B<_ extends core::Object? = dynamic, _ extends self::AA> extends self::A<self::BB, self::BB> { | ||
synthetic constructor •() → self::B<self::B::_%, self::B::_> | ||
: super self::A::•() | ||
; | ||
method foo<_ extends self::BB>([wildcard core::int _ = #C1]) → core::int | ||
return 1; | ||
} | ||
class C<T extends core::Object? = dynamic, _ extends self::BB> extends self::A<self::C::T%, self::BB> { | ||
static const field core::int _ = #C2; | ||
synthetic constructor •() → self::C<self::C::T%, self::C::_> | ||
: super self::A::•() | ||
; | ||
} | ||
class D<_ extends core::Object? = dynamic, _ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::D<self::D::_%, self::D::_%> | ||
: super core::Object::•() | ||
; | ||
} | ||
class DoesNotUseTypeVariable<_ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::DoesNotUseTypeVariable<self::DoesNotUseTypeVariable::_%> | ||
: super core::Object::•() | ||
; | ||
method returnsBB() → core::Type { | ||
return #C3; | ||
} | ||
} | ||
|
||
constants { | ||
#C1 = 2 | ||
#C2 = 1 | ||
#C3 = TypeLiteralConstant(self::BB) | ||
} |
52 changes: 52 additions & 0 deletions
52
pkg/front_end/testcases/wildcard_variables/class_type_parameters.dart.strong.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,52 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
typedef _ = self::BB; | ||
class AA extends core::Object { | ||
synthetic constructor •() → self::AA | ||
: super core::Object::•() | ||
; | ||
} | ||
class BB extends self::AA { | ||
synthetic constructor •() → self::BB | ||
: super self::AA::•() | ||
; | ||
} | ||
class A<T extends core::Object? = dynamic, U extends self::AA> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::T%, self::A::U> | ||
: super core::Object::•() | ||
; | ||
} | ||
class B<_ extends core::Object? = dynamic, _ extends self::AA> extends self::A<self::BB, self::BB> { | ||
synthetic constructor •() → self::B<self::B::_%, self::B::_> | ||
: super self::A::•() | ||
; | ||
method foo<_ extends self::BB>([wildcard core::int _ = #C1]) → core::int | ||
return 1; | ||
} | ||
class C<T extends core::Object? = dynamic, _ extends self::BB> extends self::A<self::C::T%, self::BB> { | ||
static const field core::int _ = #C2; | ||
synthetic constructor •() → self::C<self::C::T%, self::C::_> | ||
: super self::A::•() | ||
; | ||
} | ||
class D<_ extends core::Object? = dynamic, _ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::D<self::D::_%, self::D::_%> | ||
: super core::Object::•() | ||
; | ||
} | ||
class DoesNotUseTypeVariable<_ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::DoesNotUseTypeVariable<self::DoesNotUseTypeVariable::_%> | ||
: super core::Object::•() | ||
; | ||
method returnsBB() → core::Type { | ||
return #C3; | ||
} | ||
} | ||
|
||
constants { | ||
#C1 = 2 | ||
#C2 = 1 | ||
#C3 = TypeLiteralConstant(self::BB) | ||
} |
38 changes: 38 additions & 0 deletions
38
pkg/front_end/testcases/wildcard_variables/class_type_parameters.dart.strong.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,38 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
typedef _ = self::BB; | ||
class AA extends core::Object { | ||
synthetic constructor •() → self::AA | ||
; | ||
} | ||
class BB extends self::AA { | ||
synthetic constructor •() → self::BB | ||
; | ||
} | ||
class A<T extends core::Object? = dynamic, U extends self::AA> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::T%, self::A::U> | ||
; | ||
} | ||
class B<_ extends core::Object? = dynamic, _ extends self::AA> extends self::A<self::BB, self::BB> { | ||
synthetic constructor •() → self::B<self::B::_%, self::B::_> | ||
; | ||
method foo<_ extends self::BB>([wildcard core::int _ = 2]) → core::int | ||
; | ||
} | ||
class C<T extends core::Object? = dynamic, _ extends self::BB> extends self::A<self::C::T%, self::BB> { | ||
static const field core::int _ = 1; | ||
synthetic constructor •() → self::C<self::C::T%, self::C::_> | ||
; | ||
} | ||
class D<_ extends core::Object? = dynamic, _ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::D<self::D::_%, self::D::_%> | ||
; | ||
} | ||
class DoesNotUseTypeVariable<_ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::DoesNotUseTypeVariable<self::DoesNotUseTypeVariable::_%> | ||
; | ||
method returnsBB() → core::Type | ||
; | ||
} |
52 changes: 52 additions & 0 deletions
52
...ont_end/testcases/wildcard_variables/class_type_parameters.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,52 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
typedef _ = self::BB; | ||
class AA extends core::Object { | ||
synthetic constructor •() → self::AA | ||
: super core::Object::•() | ||
; | ||
} | ||
class BB extends self::AA { | ||
synthetic constructor •() → self::BB | ||
: super self::AA::•() | ||
; | ||
} | ||
class A<T extends core::Object? = dynamic, U extends self::AA> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::T%, self::A::U> | ||
: super core::Object::•() | ||
; | ||
} | ||
class B<_ extends core::Object? = dynamic, _ extends self::AA> extends self::A<self::BB, self::BB> { | ||
synthetic constructor •() → self::B<self::B::_%, self::B::_> | ||
: super self::A::•() | ||
; | ||
method foo<_ extends self::BB>([wildcard core::int _ = #C1]) → core::int | ||
return 1; | ||
} | ||
class C<T extends core::Object? = dynamic, _ extends self::BB> extends self::A<self::C::T%, self::BB> { | ||
static const field core::int _ = #C2; | ||
synthetic constructor •() → self::C<self::C::T%, self::C::_> | ||
: super self::A::•() | ||
; | ||
} | ||
class D<_ extends core::Object? = dynamic, _ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::D<self::D::_%, self::D::_%> | ||
: super core::Object::•() | ||
; | ||
} | ||
class DoesNotUseTypeVariable<_ extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::DoesNotUseTypeVariable<self::DoesNotUseTypeVariable::_%> | ||
: super core::Object::•() | ||
; | ||
method returnsBB() → core::Type { | ||
return #C3; | ||
} | ||
} | ||
|
||
constants { | ||
#C1 = 2 | ||
#C2 = 1 | ||
#C3 = TypeLiteralConstant(self::BB) | ||
} |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/wildcard_variables/class_type_parameters.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,21 @@ | ||
typedef _ = BB; | ||
|
||
class AA {} | ||
|
||
class BB extends AA {} | ||
|
||
class A<T, U extends AA> {} | ||
|
||
class B<_, _ extends AA> extends A<_, _> { | ||
int foo<_ extends _>([int _ = 2]) => 1; | ||
} | ||
|
||
class C<T, _ extends _> extends A<T, _> { | ||
static const int _ = 1; | ||
} | ||
|
||
class D<_, _> {} | ||
|
||
class DoesNotUseTypeVariable<_> { | ||
Type returnsBB() {} | ||
} |
21 changes: 21 additions & 0 deletions
21
...d/testcases/wildcard_variables/class_type_parameters.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,21 @@ | ||
class A<T, U extends AA> {} | ||
|
||
class AA {} | ||
|
||
class B<_, _ extends AA> extends A<_, _> { | ||
int foo<_ extends _>([int _ = 2]) => 1; | ||
} | ||
|
||
class BB extends AA {} | ||
|
||
class C<T, _ extends _> extends A<T, _> { | ||
static const int _ = 1; | ||
} | ||
|
||
class D<_, _> {} | ||
|
||
class DoesNotUseTypeVariable<_> { | ||
Type returnsBB() {} | ||
} | ||
|
||
typedef _ = BB; |