@@ -2027,6 +2027,155 @@ library
20272027''');
20282028 }
20292029
2030+ test_class_constructor_initializers_field_stringInterpolation_expression() async {
2031+ var library = await buildLibrary(r'''
2032+ class C {
2033+ final f;
2034+ const C() : f = '${42}';
2035+ }
2036+ ''');
2037+ checkElementText(library, r'''
2038+ library
2039+ reference: <testLibrary>
2040+ fragments
2041+ #F0 <testLibraryFragment>
2042+ element: <testLibrary>
2043+ classes
2044+ #F1 class C @6
2045+ element: <testLibrary>::@class::C
2046+ fields
2047+ #F2 f @18
2048+ element: <testLibrary>::@class::C::@field::f
2049+ constructors
2050+ #F3 const new
2051+ element: <testLibrary>::@class::C::@constructor::new
2052+ typeName: C
2053+ typeNameOffset: 29
2054+ getters
2055+ #F4 synthetic f
2056+ element: <testLibrary>::@class::C::@getter::f
2057+ classes
2058+ class C
2059+ reference: <testLibrary>::@class::C
2060+ firstFragment: #F1
2061+ fields
2062+ final f
2063+ reference: <testLibrary>::@class::C::@field::f
2064+ firstFragment: #F2
2065+ type: dynamic
2066+ getter: <testLibrary>::@class::C::@getter::f
2067+ constructors
2068+ const new
2069+ reference: <testLibrary>::@class::C::@constructor::new
2070+ firstFragment: #F3
2071+ constantInitializers
2072+ ConstructorFieldInitializer
2073+ fieldName: SimpleIdentifier
2074+ token: f @35
2075+ element: <testLibrary>::@class::C::@field::f
2076+ staticType: null
2077+ equals: = @37
2078+ expression: StringInterpolation
2079+ elements
2080+ InterpolationString
2081+ contents: ' @39
2082+ InterpolationExpression
2083+ leftBracket: ${ @40
2084+ expression: IntegerLiteral
2085+ literal: 42 @42
2086+ staticType: int
2087+ rightBracket: } @44
2088+ InterpolationString
2089+ contents: ' @45
2090+ staticType: String
2091+ stringValue: null
2092+ getters
2093+ synthetic f
2094+ reference: <testLibrary>::@class::C::@getter::f
2095+ firstFragment: #F4
2096+ returnType: dynamic
2097+ variable: <testLibrary>::@class::C::@field::f
2098+ ''');
2099+ }
2100+
2101+ test_class_constructor_initializers_field_stringInterpolation_identifier() async {
2102+ var library = await buildLibrary(r'''
2103+ class C {
2104+ final f;
2105+ const C(int x) : f = '$x';
2106+ }
2107+ ''');
2108+ checkElementText(library, r'''
2109+ library
2110+ reference: <testLibrary>
2111+ fragments
2112+ #F0 <testLibraryFragment>
2113+ element: <testLibrary>
2114+ classes
2115+ #F1 class C @6
2116+ element: <testLibrary>::@class::C
2117+ fields
2118+ #F2 f @18
2119+ element: <testLibrary>::@class::C::@field::f
2120+ constructors
2121+ #F3 const new
2122+ element: <testLibrary>::@class::C::@constructor::new
2123+ typeName: C
2124+ typeNameOffset: 29
2125+ formalParameters
2126+ #F4 x @35
2127+ element: <testLibrary>::@class::C::@constructor::new::@formalParameter::x
2128+ getters
2129+ #F5 synthetic f
2130+ element: <testLibrary>::@class::C::@getter::f
2131+ classes
2132+ class C
2133+ reference: <testLibrary>::@class::C
2134+ firstFragment: #F1
2135+ fields
2136+ final f
2137+ reference: <testLibrary>::@class::C::@field::f
2138+ firstFragment: #F2
2139+ type: dynamic
2140+ getter: <testLibrary>::@class::C::@getter::f
2141+ constructors
2142+ const new
2143+ reference: <testLibrary>::@class::C::@constructor::new
2144+ firstFragment: #F3
2145+ formalParameters
2146+ #E0 requiredPositional x
2147+ firstFragment: #F4
2148+ type: int
2149+ constantInitializers
2150+ ConstructorFieldInitializer
2151+ fieldName: SimpleIdentifier
2152+ token: f @40
2153+ element: <testLibrary>::@class::C::@field::f
2154+ staticType: null
2155+ equals: = @42
2156+ expression: StringInterpolation
2157+ elements
2158+ InterpolationString
2159+ contents: ' @44
2160+ InterpolationExpression
2161+ leftBracket: $ @45
2162+ expression: SimpleIdentifier
2163+ token: x @46
2164+ element: <testLibrary>::@class::C::@constructor::new::@formalParameter::x
2165+ staticType: int
2166+ InterpolationString
2167+ contents: ' @47
2168+ staticType: String
2169+ stringValue: null
2170+ getters
2171+ synthetic f
2172+ reference: <testLibrary>::@class::C::@getter::f
2173+ firstFragment: #F5
2174+ returnType: dynamic
2175+ variable: <testLibrary>::@class::C::@field::f
2176+ ''');
2177+ }
2178+
20302179 test_class_constructor_initializers_field_withParameter() async {
20312180 var library = await buildLibrary('''
20322181class C {
0 commit comments