[CFE] Expression compilation: Fix incorrect marking as non-static for 'instance extensions'
Fixes https://github.com/dart-lang/sdk/issues/62144 Change-Id: I0c8a9c3faedca0171501f1e6ea384772f03eb822 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472863 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
committed by
Commit Queue
parent
9e4bb73f8e
commit
6cfd130c30
@@ -1997,7 +1997,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
bool isExtensionOrExtensionType = false;
|
||||
bool isExtensionOrExtensionTypeInstanceMember = false;
|
||||
String? extensionName;
|
||||
if (usedMethodName != null) {
|
||||
int indexOfDot = usedMethodName.indexOf(".");
|
||||
@@ -2023,16 +2023,14 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
||||
}
|
||||
extensionName = beforeDot;
|
||||
if (builder is ExtensionBuilder) {
|
||||
isExtensionOrExtensionType = true;
|
||||
offsetToUse = builder.fileOffset;
|
||||
Builder? subBuilder = builder.lookupLocalMember(afterDot)?.getable;
|
||||
if (subBuilder is MemberBuilder) {
|
||||
if (subBuilder.isExtensionInstanceMember) {
|
||||
isStatic = false;
|
||||
isExtensionOrExtensionTypeInstanceMember = true;
|
||||
}
|
||||
}
|
||||
} else if (builder is ExtensionTypeDeclarationBuilder) {
|
||||
isExtensionOrExtensionType = true;
|
||||
offsetToUse = builder.fileOffset;
|
||||
Builder? subBuilder = builder.lookupLocalMember(afterDot)?.getable;
|
||||
if (subBuilder is MemberBuilder) {
|
||||
@@ -2060,7 +2058,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
||||
usedDefinitions[syntheticThisName] = substitution
|
||||
.substituteType(positionals.first.type);
|
||||
}
|
||||
isStatic = false;
|
||||
isExtensionOrExtensionTypeInstanceMember = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2085,9 +2083,9 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
||||
for (String name in usedDefinitions.keys) {
|
||||
if (isLegalIdentifier(name)) continue;
|
||||
if (isExtensionThisName(name) &&
|
||||
!isStatic &&
|
||||
isExtensionOrExtensionType) {
|
||||
// Accept #this for extensions and extension types.
|
||||
isExtensionOrExtensionTypeInstanceMember) {
|
||||
// Accept #this for "instance members" on extensions and
|
||||
// extension types.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2226,8 +2224,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
||||
type: def.value,
|
||||
)..fileOffset = offsetToUse ?? libraryBuilder.library.fileOffset;
|
||||
|
||||
if (isExtensionOrExtensionType &&
|
||||
!isStatic &&
|
||||
if (isExtensionOrExtensionTypeInstanceMember &&
|
||||
isExtensionThisName(def.key) &&
|
||||
extensionThis == null) {
|
||||
// The `#this` variable is special.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::Foo% /* erasure=dart.core::int, declared=! */ #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::Foo% /* erasure=dart.core::int, declared=! */ #this) → dynamic
|
||||
return #this as{Unchecked} dart.core::int;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::Foo% /* erasure=dart.core::int, declared=! */ #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::Foo% /* erasure=dart.core::int, declared=! */ #this) → dynamic
|
||||
return #this as{Unchecked} dart.core::int;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::Foo% /* erasure=dart.core::int, declared=! */ #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::Foo% /* erasure=dart.core::int, declared=! */ #this) → dynamic
|
||||
return #this as{Unchecked} dart.core::int;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr<T extends dart.core::Enum>(lowered #lib1::Foo<#lib2::debugExpr::T>% /* erasure=dart.core::int, declared=! */ #this, #lib2::debugExpr::T constant) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr<T extends dart.core::Enum>(lowered #lib1::Foo<#lib2::debugExpr::T>% /* erasure=dart.core::int, declared=! */ #this, #lib2::debugExpr::T constant) → dynamic
|
||||
return constant.{dart.core::Enum::index}{dart.core::int};
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::int #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::int #this) → dynamic
|
||||
return #this;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dart.core::int offset, lowered dart.core::String #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dart.core::int offset, lowered dart.core::String #this) → dynamic
|
||||
return offset.{dart.core::num::+}(#this.{dart.core::String::length}{dart.core::int}){(dart.core::num) → dart.core::int};
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::int #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::int #this) → dynamic
|
||||
return #this;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::ExtensionType% /* erasure=dart.core::String, declared=! */ #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::ExtensionType% /* erasure=dart.core::String, declared=! */ #this) → dynamic
|
||||
return #this as{Unchecked} dart.core::String;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::ExtensionType% /* erasure=dart.core::String, declared=! */ #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered #lib1::ExtensionType% /* erasure=dart.core::String, declared=! */ #this) → dynamic
|
||||
return (() → Null {
|
||||
#this as{Unchecked} dart.core::String;
|
||||
(#this as{Unchecked} dart.core::String).{dart.core::String::codeUnitAt}(0){(dart.core::int) → dart.core::int};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr<E extends dart.core::String>(lowered #lib1::ExtensionType<#lib2::debugExpr::E>% /* erasure=#lib2::debugExpr::E, declared=! */ #this) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr<E extends dart.core::String>(lowered #lib1::ExtensionType<#lib2::debugExpr::E>% /* erasure=#lib2::debugExpr::E, declared=! */ #this) → dynamic
|
||||
return (() → Null {
|
||||
#this{dynamic}.s;
|
||||
#this{dynamic}.s{dynamic}.codeUnitAt(0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::String #this, dart.core::String str) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::String #this, dart.core::String str) → dynamic
|
||||
return str;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Errors: {
|
||||
}
|
||||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::String #this, dart.core::String str) → dynamic
|
||||
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(lowered dart.core::String #this, dart.core::String str) → dynamic
|
||||
return str;
|
||||
|
||||
Reference in New Issue
Block a user