mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[cfe] Handle RecordType in isInstantiatedVisitor
Closes #50021 Change-Id: Ifb608247d0ecef3de4388bec7891afc8be00f998 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260112 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
b85443e333
commit
24c8a19439
|
@ -4679,7 +4679,7 @@ bool isInstantiated(DartType type) {
|
|||
return type.accept(new IsInstantiatedVisitor());
|
||||
}
|
||||
|
||||
class IsInstantiatedVisitor extends DartTypeVisitor<bool> {
|
||||
class IsInstantiatedVisitor implements DartTypeVisitor<bool> {
|
||||
final _availableVariables = new Set<TypeParameter>();
|
||||
|
||||
bool isInstantiated(DartType type) {
|
||||
|
@ -4739,6 +4739,23 @@ class IsInstantiatedVisitor extends DartTypeVisitor<bool> {
|
|||
|
||||
@override
|
||||
bool visitNeverType(NeverType node) => true;
|
||||
|
||||
@override
|
||||
bool visitRecordType(RecordType node) {
|
||||
return node.positional.every((p) => p.accept(this)) &&
|
||||
node.named.every((p) => p.type.accept(this));
|
||||
}
|
||||
|
||||
@override
|
||||
bool visitExtensionType(ExtensionType node) {
|
||||
return node.typeArguments
|
||||
.every((DartType typeArgument) => typeArgument.accept(this));
|
||||
}
|
||||
|
||||
@override
|
||||
bool visitIntersectionType(IntersectionType node) {
|
||||
return node.left.accept(this) && node.right.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool _isFormalParameter(VariableDeclaration variable) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2022, 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.
|
||||
|
||||
class C<T> {
|
||||
void method() {
|
||||
C<(num, {String name})>.new; // Const
|
||||
C<(T, {String name})>.new; // Non-const
|
||||
C<(num, {T name})>.new; // Non-const
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object? = dynamic> extends core::Object {
|
||||
synthetic constructor •() → self::C<self::C::T%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → void {
|
||||
#C2;
|
||||
#C1<(self::C::T%, {required name: core::String})>;
|
||||
#C1<(core::num, {required name: self::C::T%})>;
|
||||
}
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = constructor-tearoff self::C::•
|
||||
#C2 = instantiation #C1 <(core::num, {required name: core::String})>
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object? = dynamic> extends core::Object {
|
||||
synthetic constructor •() → self::C<self::C::T%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → void {
|
||||
#C2;
|
||||
#C1<(self::C::T%, {required name: core::String})>;
|
||||
#C1<(core::num, {required name: self::C::T%})>;
|
||||
}
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = constructor-tearoff self::C::•
|
||||
#C2 = instantiation #C1 <(core::num, {required name: core::String})>
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
class C<T> {
|
||||
void method() {}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
class C<T> {
|
||||
void method() {}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object? = dynamic> extends core::Object {
|
||||
synthetic constructor •() → self::C<self::C::T%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → void {
|
||||
#C2;
|
||||
#C1<(self::C::T%, {required name: core::String})>;
|
||||
#C1<(core::num, {required name: self::C::T%})>;
|
||||
}
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = constructor-tearoff self::C::•
|
||||
#C2 = instantiation #C1 <(core::num*, {required name: core::String*})*>
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object? = dynamic> extends core::Object {
|
||||
synthetic constructor •() → self::C<self::C::T%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → void {
|
||||
#C2;
|
||||
#C1<(self::C::T%, {required name: core::String})>;
|
||||
#C1<(core::num, {required name: self::C::T%})>;
|
||||
}
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = constructor-tearoff self::C::•
|
||||
#C2 = instantiation #C1 <(core::num*, {required name: core::String*})*>
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object? = dynamic> extends core::Object {
|
||||
synthetic constructor •() → self::C<self::C::T%>
|
||||
;
|
||||
method method() → void
|
||||
;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object? = dynamic> extends core::Object {
|
||||
synthetic constructor •() → self::C<self::C::T%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → void {
|
||||
#C2;
|
||||
#C1<(self::C::T%, {required name: core::String})>;
|
||||
#C1<(core::num, {required name: self::C::T%})>;
|
||||
}
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = constructor-tearoff self::C::•
|
||||
#C2 = instantiation #C1 <(core::num*, {required name: core::String*})*>
|
||||
}
|
Loading…
Reference in a new issue