[FIR] Don't set up expected type for function body

This commit is contained in:
Dmitriy Novozhilov
2020-03-13 13:09:33 +03:00
parent 813003e12e
commit 820da6edaa
19 changed files with 199 additions and 186 deletions
@@ -238,13 +238,19 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
} else { } else {
returnTypeRef returnTypeRef
} }
val resolutionMode = if (expectedReturnTypeRef.coneTypeSafe<ConeKotlinType>() == session.builtinTypes.unitType.type) {
ResolutionMode.ContextIndependent
} else {
withExpectedType(expectedReturnTypeRef)
}
val receiverTypeRef = owner.receiverTypeRef val receiverTypeRef = owner.receiverTypeRef
if (receiverTypeRef != null) { if (receiverTypeRef != null) {
withLabelAndReceiverType(owner.name, owner, receiverTypeRef.coneTypeUnsafe()) { withLabelAndReceiverType(owner.name, owner, receiverTypeRef.coneTypeUnsafe()) {
transformFunctionWithGivenSignature(accessor, expectedReturnTypeRef) transformFunctionWithGivenSignature(accessor, resolutionMode)
} }
} else { } else {
transformFunctionWithGivenSignature(accessor, expectedReturnTypeRef) transformFunctionWithGivenSignature(accessor, resolutionMode)
} }
} }
@@ -392,10 +398,10 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
val receiverTypeRef = simpleFunction.receiverTypeRef val receiverTypeRef = simpleFunction.receiverTypeRef
if (receiverTypeRef != null) { if (receiverTypeRef != null) {
withLabelAndReceiverType(simpleFunction.name, simpleFunction, receiverTypeRef.coneTypeUnsafe()) { withLabelAndReceiverType(simpleFunction.name, simpleFunction, receiverTypeRef.coneTypeUnsafe()) {
transformFunctionWithGivenSignature(simpleFunction, returnTypeRef) transformFunctionWithGivenSignature(simpleFunction, ResolutionMode.ContextIndependent)
} }
} else { } else {
transformFunctionWithGivenSignature(simpleFunction, returnTypeRef) transformFunctionWithGivenSignature(simpleFunction, ResolutionMode.ContextIndependent)
} }
} }
} }
@@ -403,14 +409,14 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
private fun <F : FirFunction<F>> transformFunctionWithGivenSignature( private fun <F : FirFunction<F>> transformFunctionWithGivenSignature(
function: F, function: F,
returnTypeRef: FirTypeRef, resolutionMode: ResolutionMode,
): CompositeTransformResult<F> { ): CompositeTransformResult<F> {
if (function is FirSimpleFunction) { if (function is FirSimpleFunction) {
components.storeFunction(function) components.storeFunction(function)
} }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
val result = transformFunction(function, withExpectedType(returnTypeRef)).single as F val result = transformFunction(function, resolutionMode).single as F
val body = result.body val body = result.body
if (result.returnTypeRef is FirImplicitTypeRef) { if (result.returnTypeRef is FirImplicitTypeRef) {
@@ -68,7 +68,7 @@ FILE: operatorsOverLiterals.kt
^ Int(1) ^ Int(1)
} }
) )
Int(1).R|<local>/plus|(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> { Int(1).R|kotlin/Int.plus|(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1) ^ Int(1)
} }
)) ))
@@ -31,9 +31,9 @@ FILE: threeReceiversCorrect.kt
(this@R|special/anonymous|, R|<local>/b|).R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/c|) (this@R|special/anonymous|, R|<local>/b|).R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/c|)
} }
) )
R|/with|<R|B|, R|kotlin/Unit|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(): R|kotlin/Unit| { ^ R|/with|<R|B|, R|kotlin/Unit|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/c|) this@R|special/anonymous|.R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/c|)
R|/with|<R|C|, R|kotlin/Unit|>(R|<local>/c|, <L> = with@fun R|C|.<anonymous>(): R|kotlin/Unit| { ^ R|/with|<R|C|, R|kotlin/Unit|>(R|<local>/c|, <L> = with@fun R|C|.<anonymous>(): R|kotlin/Unit| {
(this@R|special/anonymous|, this@R|special/anonymous|).R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(this@R|special/anonymous|) (this@R|special/anonymous|, this@R|special/anonymous|).R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(this@R|special/anonymous|)
} }
) )
@@ -0,0 +1,6 @@
fun <T> id(x: T): T = x
fun <K> select(x: K, y: K): K = TODO()
fun test() {
select(id { it.inv() }, id<(Int) -> Unit> { })
}
@@ -0,0 +1,16 @@
FILE: complexLambdaWithTypeVariableAsExpectedType.kt
public final fun <T> id(x: R|T|): R|T| {
^id R|<local>/x|
}
public final fun <K> select(x: R|K|, y: R|K|): R|K| {
^select R|kotlin/TODO|()
}
public final fun test(): R|kotlin/Unit| {
R|/select|<R|(kotlin/Int) -> kotlin/Unit|>(R|/id|<R|(kotlin/Int) -> kotlin/Int|>(<L> = id@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
^ R|<local>/it|.R|kotlin/Int.inv|()
}
), R|/id|<R|(kotlin/Int) -> kotlin/Unit|>(<L> = id@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| {
Unit
}
))
}
@@ -226,25 +226,24 @@ digraph implicitReceivers_kt {
87 [label="Function call: this@R|special/anonymous|.R|/A.foo|()"]; 87 [label="Function call: this@R|special/anonymous|.R|/A.foo|()"];
88 [label="Exit function anonymousFunction"]; 88 [label="Exit function anonymousFunction"];
} }
89 [label="Call arguments union" style="filled" fillcolor=yellow]; 89 [label="Postponed exit from lambda"];
90 [label="Postponed exit from lambda"]; 90 [label="Function call: R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(...)"];
91 [label="Function call: R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(...)"]; 91 [label="Exit function anonymousFunction"];
92 [label="Exit function anonymousFunction"];
} }
93 [label="Call arguments union" style="filled" fillcolor=yellow]; 92 [label="Call arguments union" style="filled" fillcolor=yellow];
94 [label="Postponed exit from lambda"]; 93 [label="Postponed exit from lambda"];
95 [label="Function call: R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(...)"]; 94 [label="Function call: R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(...)"];
96 [label="Exit function test_3" style="filled" fillcolor=red]; 95 [label="Exit function test_3" style="filled" fillcolor=red];
} }
66 -> {67}; 66 -> {67};
67 -> {68}; 67 -> {68};
68 -> {69}; 68 -> {69};
68 -> {94} [color=red]; 68 -> {93} [color=red];
69 -> {70}; 69 -> {70};
70 -> {71}; 70 -> {71};
71 -> {72}; 71 -> {72};
71 -> {90} [color=red]; 71 -> {89} [color=red];
72 -> {73}; 72 -> {73};
73 -> {74}; 73 -> {74};
74 -> {75}; 74 -> {75};
@@ -263,115 +262,115 @@ digraph implicitReceivers_kt {
85 -> {86}; 85 -> {86};
86 -> {87}; 86 -> {87};
87 -> {88}; 87 -> {88};
88 -> {90} [color=green]; 88 -> {89} [color=green];
88 -> {89} [color=red]; 88 -> {92} [color=red];
89 -> {91} [color=red]; 89 -> {90};
90 -> {91} [color=green]; 90 -> {91};
91 -> {92}; 91 -> {93} [color=green];
92 -> {94} [color=green]; 91 -> {92} [color=red];
92 -> {93} [color=red]; 92 -> {94} [color=red];
93 -> {95} [color=red]; 93 -> {94} [color=green];
94 -> {95} [color=green]; 94 -> {95};
95 -> {96};
subgraph cluster_21 { subgraph cluster_21 {
color=red color=red
97 [label="Enter function test_4" style="filled" fillcolor=red]; 96 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_22 { subgraph cluster_22 {
color=blue color=blue
98 [label="Enter when"]; 97 [label="Enter when"];
subgraph cluster_23 { subgraph cluster_23 {
color=blue color=blue
99 [label="Enter when branch condition "]; 98 [label="Enter when branch condition "];
100 [label="Access variable this@R|/test_4|"]; 99 [label="Access variable this@R|/test_4|"];
101 [label="Type operator: (this@R|/test_4| !is R|A|)"]; 100 [label="Type operator: (this@R|/test_4| !is R|A|)"];
102 [label="Exit when branch condition"]; 101 [label="Exit when branch condition"];
} }
subgraph cluster_24 { subgraph cluster_24 {
color=blue color=blue
103 [label="Enter when branch condition else"]; 102 [label="Enter when branch condition else"];
104 [label="Exit when branch condition"]; 103 [label="Exit when branch condition"];
} }
105 [label="Enter when branch result"]; 104 [label="Enter when branch result"];
subgraph cluster_25 { subgraph cluster_25 {
color=blue color=blue
106 [label="Enter block"]; 105 [label="Enter block"];
subgraph cluster_26 { subgraph cluster_26 {
color=blue color=blue
107 [label="Enter when"]; 106 [label="Enter when"];
subgraph cluster_27 { subgraph cluster_27 {
color=blue color=blue
108 [label="Enter when branch condition "]; 107 [label="Enter when branch condition "];
109 [label="Access variable this@R|/test_4|"]; 108 [label="Access variable this@R|/test_4|"];
110 [label="Type operator: (this@R|/test_4| !is R|B|)"]; 109 [label="Type operator: (this@R|/test_4| !is R|B|)"];
111 [label="Exit when branch condition"]; 110 [label="Exit when branch condition"];
} }
subgraph cluster_28 { subgraph cluster_28 {
color=blue color=blue
112 [label="Enter when branch condition else"]; 111 [label="Enter when branch condition else"];
113 [label="Exit when branch condition"]; 112 [label="Exit when branch condition"];
} }
114 [label="Enter when branch result"]; 113 [label="Enter when branch result"];
subgraph cluster_29 { subgraph cluster_29 {
color=blue color=blue
115 [label="Enter block"]; 114 [label="Enter block"];
116 [label="Access variable this@R|/test_4|"]; 115 [label="Access variable this@R|/test_4|"];
116 [label="Function call: this@R|/test_4|.R|/A.foo|()"];
117 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; 117 [label="Function call: this@R|/test_4|.R|/A.foo|()"];
118 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; 118 [label="Access variable this@R|/test_4|"];
119 [label="Access variable this@R|/test_4|"]; 119 [label="Function call: this@R|/test_4|.R|/B.bar|()"];
120 [label="Function call: this@R|/test_4|.R|/B.bar|()"]; 120 [label="Function call: this@R|/test_4|.R|/B.bar|()"];
121 [label="Function call: this@R|/test_4|.R|/B.bar|()"]; 121 [label="Exit block"];
122 [label="Exit block"];
} }
123 [label="Exit when branch result"]; 122 [label="Exit when branch result"];
124 [label="Enter when branch result"]; 123 [label="Enter when branch result"];
subgraph cluster_30 { subgraph cluster_30 {
color=blue color=blue
125 [label="Enter block"]; 124 [label="Enter block"];
126 [label="Access variable this@R|/test_4|"]; 125 [label="Access variable this@R|/test_4|"];
127 [label="Function call: this@R|/test_4|.<Unresolved name: bar>#()"]; 126 [label="Function call: this@R|/test_4|.<Unresolved name: bar>#()"];
128 [label="Function call: <Unresolved name: bar>#()"]; 127 [label="Function call: <Unresolved name: bar>#()"];
129 [label="Access variable this@R|/test_4|"]; 128 [label="Access variable this@R|/test_4|"];
129 [label="Function call: this@R|/test_4|.R|/A.foo|()"];
130 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; 130 [label="Function call: this@R|/test_4|.R|/A.foo|()"];
131 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; 131 [label="Exit block"];
132 [label="Exit block"];
} }
133 [label="Exit when branch result"]; 132 [label="Exit when branch result"];
134 [label="Exit when"]; 133 [label="Exit when"];
} }
135 [label="Exit block"]; 134 [label="Exit block"];
} }
136 [label="Exit when branch result"]; 135 [label="Exit when branch result"];
137 [label="Enter when branch result"]; 136 [label="Enter when branch result"];
subgraph cluster_31 { subgraph cluster_31 {
color=blue color=blue
138 [label="Enter block"]; 137 [label="Enter block"];
139 [label="Access variable this@R|/test_4|"]; 138 [label="Access variable this@R|/test_4|"];
140 [label="Function call: this@R|/test_4|.<Unresolved name: foo>#()"]; 139 [label="Function call: this@R|/test_4|.<Unresolved name: foo>#()"];
141 [label="Function call: <Unresolved name: foo>#()"]; 140 [label="Function call: <Unresolved name: foo>#()"];
142 [label="Access variable this@R|/test_4|"]; 141 [label="Access variable this@R|/test_4|"];
143 [label="Function call: this@R|/test_4|.<Unresolved name: bar>#()"]; 142 [label="Function call: this@R|/test_4|.<Unresolved name: bar>#()"];
144 [label="Function call: <Unresolved name: bar>#()"]; 143 [label="Function call: <Unresolved name: bar>#()"];
145 [label="Exit block"]; 144 [label="Exit block"];
} }
146 [label="Exit when branch result"]; 145 [label="Exit when branch result"];
147 [label="Exit when"]; 146 [label="Exit when"];
} }
148 [label="Access variable this@R|/test_4|"]; 147 [label="Access variable this@R|/test_4|"];
149 [label="Function call: this@R|/test_4|.<Unresolved name: foo>#()"]; 148 [label="Function call: this@R|/test_4|.<Unresolved name: foo>#()"];
150 [label="Function call: <Unresolved name: foo>#()"]; 149 [label="Function call: <Unresolved name: foo>#()"];
151 [label="Access variable this@R|/test_4|"]; 150 [label="Access variable this@R|/test_4|"];
152 [label="Function call: this@R|/test_4|.<Unresolved name: bar>#()"]; 151 [label="Function call: this@R|/test_4|.<Unresolved name: bar>#()"];
153 [label="Function call: <Unresolved name: bar>#()"]; 152 [label="Function call: <Unresolved name: bar>#()"];
154 [label="Exit function test_4" style="filled" fillcolor=red]; 153 [label="Exit function test_4" style="filled" fillcolor=red];
} }
96 -> {97};
97 -> {98}; 97 -> {98};
98 -> {99}; 98 -> {99};
99 -> {100}; 99 -> {100};
100 -> {101}; 100 -> {101};
101 -> {102}; 101 -> {136 102};
102 -> {137 103}; 102 -> {103};
103 -> {104}; 103 -> {104};
104 -> {105}; 104 -> {105};
105 -> {106}; 105 -> {106};
@@ -379,8 +378,8 @@ digraph implicitReceivers_kt {
107 -> {108}; 107 -> {108};
108 -> {109}; 108 -> {109};
109 -> {110}; 109 -> {110};
110 -> {111}; 110 -> {123 111};
111 -> {124 112}; 111 -> {112};
112 -> {113}; 112 -> {113};
113 -> {114}; 113 -> {114};
114 -> {115}; 114 -> {115};
@@ -391,8 +390,8 @@ digraph implicitReceivers_kt {
119 -> {120}; 119 -> {120};
120 -> {121}; 120 -> {121};
121 -> {122}; 121 -> {122};
122 -> {123}; 122 -> {133};
123 -> {134}; 123 -> {124};
124 -> {125}; 124 -> {125};
125 -> {126}; 125 -> {126};
126 -> {127}; 126 -> {127};
@@ -404,8 +403,8 @@ digraph implicitReceivers_kt {
132 -> {133}; 132 -> {133};
133 -> {134}; 133 -> {134};
134 -> {135}; 134 -> {135};
135 -> {136}; 135 -> {146};
136 -> {147}; 136 -> {137};
137 -> {138}; 137 -> {138};
138 -> {139}; 138 -> {139};
139 -> {140}; 139 -> {140};
@@ -422,60 +421,59 @@ digraph implicitReceivers_kt {
150 -> {151}; 150 -> {151};
151 -> {152}; 151 -> {152};
152 -> {153}; 152 -> {153};
153 -> {154};
subgraph cluster_32 { subgraph cluster_32 {
color=red color=red
155 [label="Enter function test_5" style="filled" fillcolor=red]; 154 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_33 { subgraph cluster_33 {
color=blue color=blue
156 [label="Enter when"]; 155 [label="Enter when"];
subgraph cluster_34 { subgraph cluster_34 {
color=blue color=blue
157 [label="Enter when branch condition "]; 156 [label="Enter when branch condition "];
158 [label="Access variable this@R|/test_5|"]; 157 [label="Access variable this@R|/test_5|"];
159 [label="Type operator: (this@R|/test_5| is R|kotlin/collections/List<*>|)"]; 158 [label="Type operator: (this@R|/test_5| is R|kotlin/collections/List<*>|)"];
160 [label="Exit when branch condition"]; 159 [label="Exit when branch condition"];
} }
subgraph cluster_35 { subgraph cluster_35 {
color=blue color=blue
161 [label="Enter when branch condition "]; 160 [label="Enter when branch condition "];
162 [label="Access variable this@R|/test_5|"]; 161 [label="Access variable this@R|/test_5|"];
163 [label="Type operator: (this@R|/test_5| is R|kotlin/String|)"]; 162 [label="Type operator: (this@R|/test_5| is R|kotlin/String|)"];
164 [label="Exit when branch condition"]; 163 [label="Exit when branch condition"];
} }
subgraph cluster_36 { subgraph cluster_36 {
color=blue color=blue
165 [label="Enter when branch condition else"]; 164 [label="Enter when branch condition else"];
166 [label="Exit when branch condition"]; 165 [label="Exit when branch condition"];
} }
167 [label="Enter when branch result"]; 166 [label="Enter when branch result"];
subgraph cluster_37 { subgraph cluster_37 {
color=blue color=blue
168 [label="Enter block"]; 167 [label="Enter block"];
169 [label="Const: Int(0)"]; 168 [label="Const: Int(0)"];
170 [label="Exit block"]; 169 [label="Exit block"];
} }
171 [label="Exit when branch result"]; 170 [label="Exit when branch result"];
172 [label="Enter when branch result"]; 171 [label="Enter when branch result"];
subgraph cluster_38 { subgraph cluster_38 {
color=blue color=blue
173 [label="Enter block"]; 172 [label="Enter block"];
174 [label="Access variable R|kotlin/String.length|"]; 173 [label="Access variable R|kotlin/String.length|"];
175 [label="Exit block"]; 174 [label="Exit block"];
} }
176 [label="Exit when branch result"]; 175 [label="Exit when branch result"];
177 [label="Enter when branch result"]; 176 [label="Enter when branch result"];
subgraph cluster_39 { subgraph cluster_39 {
color=blue color=blue
178 [label="Enter block"]; 177 [label="Enter block"];
179 [label="Access variable R|kotlin/collections/List.size|"]; 178 [label="Access variable R|kotlin/collections/List.size|"];
180 [label="Exit block"]; 179 [label="Exit block"];
} }
181 [label="Exit when branch result"]; 180 [label="Exit when branch result"];
182 [label="Exit when"]; 181 [label="Exit when"];
} }
183 [label="Jump: ^test_5 when () { 182 [label="Jump: ^test_5 when () {
(this@R|/test_5| is R|kotlin/collections/List<*>|) -> { (this@R|/test_5| is R|kotlin/collections/List<*>|) -> {
this@R|/test_5|.R|kotlin/collections/List.size| this@R|/test_5|.R|kotlin/collections/List.size|
} }
@@ -487,60 +485,60 @@ digraph implicitReceivers_kt {
} }
} }
"]; "];
184 [label="Stub" style="filled" fillcolor=gray]; 183 [label="Stub" style="filled" fillcolor=gray];
185 [label="Exit function test_5" style="filled" fillcolor=red]; 184 [label="Exit function test_5" style="filled" fillcolor=red];
} }
154 -> {155};
155 -> {156}; 155 -> {156};
156 -> {157}; 156 -> {157};
157 -> {158}; 157 -> {158};
158 -> {159}; 158 -> {159};
159 -> {160}; 159 -> {176 160};
160 -> {177 161}; 160 -> {161};
161 -> {162}; 161 -> {162};
162 -> {163}; 162 -> {163};
163 -> {164}; 163 -> {171 164};
164 -> {172 165}; 164 -> {165};
165 -> {166}; 165 -> {166};
166 -> {167}; 166 -> {167};
167 -> {168}; 167 -> {168};
168 -> {169}; 168 -> {169};
169 -> {170}; 169 -> {170};
170 -> {171}; 170 -> {181};
171 -> {182}; 171 -> {172};
172 -> {173}; 172 -> {173};
173 -> {174}; 173 -> {174};
174 -> {175}; 174 -> {175};
175 -> {176}; 175 -> {181};
176 -> {182}; 176 -> {177};
177 -> {178}; 177 -> {178};
178 -> {179}; 178 -> {179};
179 -> {180}; 179 -> {180};
180 -> {181}; 180 -> {181};
181 -> {182}; 181 -> {182};
182 -> {183}; 182 -> {184};
183 -> {185}; 182 -> {183} [style=dotted];
183 -> {184} [style=dotted]; 183 -> {184} [style=dotted];
184 -> {185} [style=dotted];
subgraph cluster_40 { subgraph cluster_40 {
color=red color=red
186 [label="Enter function test_6" style="filled" fillcolor=red]; 185 [label="Enter function test_6" style="filled" fillcolor=red];
187 [label="Access variable this@R|/test_6|"]; 186 [label="Access variable this@R|/test_6|"];
188 [label="Type operator: (this@R|/test_6| as R|kotlin/collections/List<*>|)"]; 187 [label="Type operator: (this@R|/test_6| as R|kotlin/collections/List<*>|)"];
189 [label="Access variable R|kotlin/collections/List.size|"]; 188 [label="Access variable R|kotlin/collections/List.size|"];
190 [label="Access variable this@R|/test_6|"]; 189 [label="Access variable this@R|/test_6|"];
191 [label="Type operator: (this@R|/test_6| as R|kotlin/String|)"]; 190 [label="Type operator: (this@R|/test_6| as R|kotlin/String|)"];
192 [label="Access variable R|kotlin/String.length|"]; 191 [label="Access variable R|kotlin/String.length|"];
193 [label="Exit function test_6" style="filled" fillcolor=red]; 192 [label="Exit function test_6" style="filled" fillcolor=red];
} }
185 -> {186};
186 -> {187}; 186 -> {187};
187 -> {188}; 187 -> {188};
188 -> {189}; 188 -> {189};
189 -> {190}; 189 -> {190};
190 -> {191}; 190 -> {191};
191 -> {192}; 191 -> {192};
192 -> {193};
} }
@@ -51,7 +51,7 @@ FILE: implicitReceivers.kt
} }
public final fun test_3(a: R|kotlin/Any|, b: R|kotlin/Any|, c: R|kotlin/Any|): R|kotlin/Unit| { public final fun test_3(a: R|kotlin/Any|, b: R|kotlin/Any|, c: R|kotlin/Any|): R|kotlin/Unit| {
R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(R|<local>/a|, <L> = wa@fun R|kotlin/Any|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> { R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(R|<local>/a|, <L> = wa@fun R|kotlin/Any|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(R|<local>/b|, <L> = wb@fun R|kotlin/Any|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> { ^ R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(R|<local>/b|, <L> = wb@fun R|kotlin/Any|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(R|<local>/c|, <L> = wc@fun R|kotlin/Any|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> { R|kotlin/with|<R|kotlin/Any|, R|kotlin/Unit|>(R|<local>/c|, <L> = wc@fun R|kotlin/Any|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
(this@R|special/anonymous| as R|A|) (this@R|special/anonymous| as R|A|)
this@R|special/anonymous|.R|/A.foo|() this@R|special/anonymous|.R|/A.foo|()
@@ -30,14 +30,14 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt
^bar R|kotlin/TODO|() ^bar R|kotlin/TODO|()
} }
public final fun test(): R|kotlin/Unit| { public final fun test(): R|kotlin/Unit| {
R|/myWith|<R|A|, R|kotlin/Unit|>(R|/A.A|(), <L> = myWith@fun R|A|.<anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> { R|/myWith|<R|A|, R|kotlin/Nothing|>(R|/A.A|(), <L> = myWith@fun R|A|.<anonymous>(): R|kotlin/Nothing| <kind=UNKNOWN> {
lval t1: R|A| = R|/bar|<R|A|>(::R|/A.foo|) lval t1: R|A| = R|/bar|<R|A|>(::R|/A.foo|)
lval t2: R|A| = R|/bar|<R|A|>(::R|/A.baz|) lval t2: R|A| = R|/bar|<R|A|>(::R|/A.baz|)
R|/myWith|<R|B|, R|kotlin/Unit|>(R|/B.B|(), <L> = myWith@fun R|B|.<anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> { ^ R|/myWith|<R|B|, R|kotlin/Nothing|>(R|/B.B|(), <L> = myWith@fun R|B|.<anonymous>(): R|kotlin/Nothing| <kind=UNKNOWN> {
lval a: R|A| = R|/bar|<R|A|>(::R|/A.foo|) lval a: R|A| = R|/bar|<R|A|>(::R|/A.foo|)
lval b: R|B| = R|/bar|<R|B|>(::R|/B.foo|) lval b: R|B| = R|/bar|<R|B|>(::R|/B.foo|)
lval t3: R|B| = R|/bar|<R|B|>(::R|/B.baz|) lval t3: R|B| = R|/bar|<R|B|>(::R|/B.baz|)
R|/bar|<R|kotlin/Unit|>(::<Unresolved reference: foo>#) ^ R|/bar|<R|kotlin/Nothing|>(::<Unresolved reference: foo>#)
} }
) )
} }
@@ -21,5 +21,5 @@ FILE: eagerAndPostponedCallableReferences.kt
lval a4: R|B| = R|/foo|<R|B|>(::R|/multiple|, ::R|/singleB|) lval a4: R|B| = R|/foo|<R|B|>(::R|/multiple|, ::R|/singleB|)
lval a5: R|A| = R|/foo|<R|A|>(::R|/singleA|, ::R|/singleA|) lval a5: R|A| = R|/foo|<R|A|>(::R|/singleA|, ::R|/singleA|)
lval a6: R|it(A & B)| = R|/foo|<R|it(A & B)|>(::R|/singleA|, ::R|/singleB|) lval a6: R|it(A & B)| = R|/foo|<R|it(A & B)|>(::R|/singleA|, ::R|/singleB|)
R|/foo|<R|kotlin/Unit|>(::<Unresolved reference: multiple>#, ::<Unresolved reference: multiple>#) R|/foo|<R|kotlin/Nothing|>(::<Unresolved reference: multiple>#, ::<Unresolved reference: multiple>#)
} }
@@ -1417,6 +1417,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/resolve/testData/resolve/problems/callableReferencesAndDefaultParameters.kt"); runTest("compiler/fir/resolve/testData/resolve/problems/callableReferencesAndDefaultParameters.kt");
} }
@TestMetadata("complexLambdaWithTypeVariableAsExpectedType.kt")
public void testComplexLambdaWithTypeVariableAsExpectedType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt");
}
@TestMetadata("definitelyNotNullAndOriginalType.kt") @TestMetadata("definitelyNotNullAndOriginalType.kt")
public void testDefinitelyNotNullAndOriginalType() throws Exception { public void testDefinitelyNotNullAndOriginalType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt"); runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt");
@@ -1417,6 +1417,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/resolve/testData/resolve/problems/callableReferencesAndDefaultParameters.kt"); runTest("compiler/fir/resolve/testData/resolve/problems/callableReferencesAndDefaultParameters.kt");
} }
@TestMetadata("complexLambdaWithTypeVariableAsExpectedType.kt")
public void testComplexLambdaWithTypeVariableAsExpectedType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt");
}
@TestMetadata("definitelyNotNullAndOriginalType.kt") @TestMetadata("definitelyNotNullAndOriginalType.kt")
public void testDefinitelyNotNullAndOriginalType() throws Exception { public void testDefinitelyNotNullAndOriginalType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt"); runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt");
@@ -1,8 +0,0 @@
Failures detected in FirBodyResolveTransformerAdapter, file: /nestedCallWithOverload.fir.kt
Cause: java.lang.RuntimeException: While resolving call R?C|/baz|(R?C|/id|(<L> = id@fun <implicit>.<anonymous>(): <implicit> {
it#.inv#()
}
), R|/id|<R|(kotlin/Int) -> kotlin/Unit|>(<L> = id@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| {
Unit
}
))
@@ -18,7 +18,7 @@ fun test() {
id(id<(Int) -> Unit>(::foo)) id(id<(Int) -> Unit>(::foo))
baz<(Int) -> Unit>(id(::foo), id(id(::foo))) baz<(Int) -> Unit>(id(::foo), id(id(::foo)))
baz(id(::foo), id(id<(Int) -> Unit>(::foo))) baz(id(::foo), id(id<(Int) -> Unit>(::foo)))
baz(id(<!UNRESOLVED_REFERENCE!>::foo<!>), id<(Int) -> Unit>(id(::foo))) baz(id(::foo), id<(Int) -> Unit>(id(::foo)))
baz(id { it.inv() }, id<(Int) -> Unit> { }) baz(id { it.inv() }, id<(Int) -> Unit> { })
} }
@@ -1,8 +0,0 @@
Failures detected in FirBodyResolveTransformerAdapter, file: /kt36044.fir.kt
Cause: java.lang.RuntimeException: While resolving call R?C|/select|(Char(a), R?C|/map|(<L> = map@fun <anonymous>(): <ERROR TYPE REF: No type for block> {
^ map@fun <implicit>.<anonymous>(): <implicit> {
String()
}
}
))
@@ -1,9 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// Issue: KT-36044
fun <A> select(x: A, f: () -> A) = f()
fun <B> map(f: () -> B) = f()
fun main() {
select('a', map { { "" } })
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
// Issue: KT-36044 // Issue: KT-36044
@@ -8,5 +8,5 @@ fun test2(f: ((String) -> Int)?) {
val a0: ((Int) -> Int)? = select2({ it -> it }, null) val a0: ((Int) -> Int)? = select2({ it -> it }, null)
val b0: ((Nothing) -> Unit)? = select2({ it -> it }, null) val b0: ((Nothing) -> Unit)? = select2({ it -> it }, null)
select3({ <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>length<!> }, f, null) select3({ it.length }, f, null)
} }
+3 -3
View File
@@ -31,7 +31,7 @@ FILE fqName:<root> fileName:/ifElseIf.kt
BRANCH BRANCH
if: CONST Boolean type=kotlin.Boolean value=true if: CONST Boolean type=kotlin.Boolean value=true
then: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=true
WHEN type=kotlin.Unit origin=IF WHEN type=kotlin.Any origin=IF
BRANCH BRANCH
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches1' type=kotlin.Boolean origin=null if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches1' type=kotlin.Boolean origin=null
then: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=true
@@ -45,14 +45,14 @@ FILE fqName:<root> fileName:/ifElseIf.kt
BRANCH BRANCH
if: CONST Boolean type=kotlin.Boolean value=true if: CONST Boolean type=kotlin.Boolean value=true
then: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=true
WHEN type=kotlin.Unit origin=IF WHEN type=kotlin.Any origin=IF
BRANCH BRANCH
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches2' type=kotlin.Boolean origin=null if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches2' type=kotlin.Boolean origin=null
then: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=true
FUN name:testEmptyBranches3 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit FUN name:testEmptyBranches3 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit
VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean
BLOCK_BODY BLOCK_BODY
WHEN type=kotlin.Unit origin=IF WHEN type=kotlin.Any origin=IF
BRANCH BRANCH
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches3' type=kotlin.Boolean origin=null if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches3' type=kotlin.Boolean origin=null
then: BLOCK type=kotlin.Unit origin=null then: BLOCK type=kotlin.Unit origin=null
+8 -7
View File
@@ -33,13 +33,14 @@ FILE fqName:<root> fileName:/nonLocalReturn.kt
block: FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA block: FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY BLOCK_BODY
CALL 'public final fun run <R> (block: kotlin.Function0<R of kotlin.run>): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.test3'
<R>: kotlin.Nothing CALL 'public final fun run <R> (block: kotlin.Function0<R of kotlin.run>): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null
block: FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA <R>: kotlin.Nothing
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing block: FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA
BLOCK_BODY FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Nothing declared in <root>.test3.<anonymous>' BLOCK_BODY
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Nothing declared in <root>.test3.<anonymous>'
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List<kotlin.Int>) returnType:kotlin.Unit FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List<kotlin.Int>) returnType:kotlin.Unit
VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List<kotlin.Int> VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List<kotlin.Int>
BLOCK_BODY BLOCK_BODY