[FIR] Fix ambiguity between Sequence.forEach and Iterable.forEach (with @HidesMembers) ^KT-50776 Fixed

This commit is contained in:
Ivan Kochurkin
2022-01-14 14:04:31 +03:00
committed by TeamCityServer
parent 4a200a2d7e
commit defb0cf611
13 changed files with 257 additions and 187 deletions
@@ -25721,6 +25721,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt"); runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt");
} }
@Test
@TestMetadata("memberWithHidesMemberAnnotationVsMemberWithout.kt")
public void testMemberWithHidesMemberAnnotationVsMemberWithout() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberWithHidesMemberAnnotationVsMemberWithout.kt");
}
@Test @Test
@TestMetadata("staticVsImplicitReceiverMember.kt") @TestMetadata("staticVsImplicitReceiverMember.kt")
public void testStaticVsImplicitReceiverMember() throws Exception { public void testStaticVsImplicitReceiverMember() throws Exception {
+155 -169
View File
@@ -19,102 +19,88 @@ digraph complex_kt {
subgraph cluster_2 { subgraph cluster_2 {
color=red color=red
4 [label="Enter function addSuppressed" style="filled" fillcolor=red]; 4 [label="Enter function closeFinally" style="filled" fillcolor=red];
subgraph cluster_3 { subgraph cluster_3 {
color=blue color=blue
5 [label="Enter block"]; 5 [label="Enter block"];
6 [label="Exit block"]; subgraph cluster_4 {
}
7 [label="Exit function addSuppressed" style="filled" fillcolor=red];
}
4 -> {5};
5 -> {6};
6 -> {7};
subgraph cluster_4 {
color=red
8 [label="Enter function closeFinally" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
9 [label="Enter block"];
subgraph cluster_6 {
color=blue color=blue
10 [label="Enter when"]; 6 [label="Enter when"];
subgraph cluster_5 {
color=blue
7 [label="Enter when branch condition "];
8 [label="Access variable this@R|/closeFinally|"];
9 [label="Const: Null(null)"];
10 [label="Equality operator =="];
11 [label="Exit when branch condition"];
}
subgraph cluster_6 {
color=blue
12 [label="Enter when branch condition "];
13 [label="Access variable R|<local>/cause|"];
14 [label="Const: Null(null)"];
15 [label="Equality operator =="];
16 [label="Exit when branch condition"];
}
subgraph cluster_7 { subgraph cluster_7 {
color=blue color=blue
11 [label="Enter when branch condition "]; 17 [label="Enter when branch condition else"];
12 [label="Access variable this@R|/closeFinally|"]; 18 [label="Exit when branch condition"];
13 [label="Const: Null(null)"];
14 [label="Equality operator =="];
15 [label="Exit when branch condition"];
} }
19 [label="Enter when branch result"];
subgraph cluster_8 { subgraph cluster_8 {
color=blue color=blue
16 [label="Enter when branch condition "]; 20 [label="Enter block"];
17 [label="Access variable R|<local>/cause|"]; subgraph cluster_9 {
18 [label="Const: Null(null)"];
19 [label="Equality operator =="];
20 [label="Exit when branch condition"];
}
subgraph cluster_9 {
color=blue
21 [label="Enter when branch condition else"];
22 [label="Exit when branch condition"];
}
23 [label="Enter when branch result"];
subgraph cluster_10 {
color=blue
24 [label="Enter block"];
subgraph cluster_11 {
color=blue color=blue
25 [label="Try expression enter"]; 21 [label="Try expression enter"];
subgraph cluster_10 {
color=blue
22 [label="Try main block enter"];
subgraph cluster_11 {
color=blue
23 [label="Enter block"];
24 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"];
25 [label="Exit block"];
}
26 [label="Try main block exit"];
}
subgraph cluster_12 { subgraph cluster_12 {
color=blue color=blue
26 [label="Try main block enter"]; 27 [label="Catch enter"];
subgraph cluster_13 { subgraph cluster_13 {
color=blue color=blue
27 [label="Enter block"]; 28 [label="Enter block"];
28 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"]; 29 [label="Access variable R|<local>/cause|"];
29 [label="Exit block"]; 30 [label="Access variable R|<local>/closeException|"];
31 [label="Function call: R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(...)"];
32 [label="Exit block"];
} }
30 [label="Try main block exit"]; 33 [label="Catch exit"];
} }
subgraph cluster_14 { 34 [label="Try expression exit"];
color=blue
31 [label="Catch enter"];
subgraph cluster_15 {
color=blue
32 [label="Enter block"];
33 [label="Access variable R|<local>/cause|"];
34 [label="Access variable R|<local>/closeException|"];
35 [label="Function call: R|<local>/cause|.R|/addSuppressed|(...)"];
36 [label="Exit block"];
}
37 [label="Catch exit"];
}
38 [label="Try expression exit"];
} }
39 [label="Exit block"]; 35 [label="Exit block"];
} }
40 [label="Exit when branch result"]; 36 [label="Exit when branch result"];
41 [label="Enter when branch result"]; 37 [label="Enter when branch result"];
subgraph cluster_16 { subgraph cluster_14 {
color=blue color=blue
42 [label="Enter block"]; 38 [label="Enter block"];
43 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"]; 39 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"];
40 [label="Exit block"];
}
41 [label="Exit when branch result"];
42 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
43 [label="Enter block"];
44 [label="Exit block"]; 44 [label="Exit block"];
} }
45 [label="Exit when branch result"]; 45 [label="Exit when branch result"];
46 [label="Enter when branch result"]; 46 [label="Exit when"];
subgraph cluster_17 {
color=blue
47 [label="Enter block"];
48 [label="Exit block"];
}
49 [label="Exit when branch result"];
50 [label="Exit when"];
} }
51 [label="Jump: ^closeFinally when () { 47 [label="Jump: ^closeFinally when () {
==(this@R|/closeFinally|, Null(null)) -> { ==(this@R|/closeFinally|, Null(null)) -> {
} }
==(R|<local>/cause|, Null(null)) -> { ==(R|<local>/cause|, Null(null)) -> {
@@ -125,174 +111,174 @@ digraph complex_kt {
this@R|/closeFinally|.R|/AutoCloseable.close|() this@R|/closeFinally|.R|/AutoCloseable.close|()
} }
catch (closeException: R|kotlin/Throwable|) { catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|/addSuppressed|(R|<local>/closeException|) R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(R|<local>/closeException|)
} }
} }
} }
"]; "];
52 [label="Stub" style="filled" fillcolor=gray]; 48 [label="Stub" style="filled" fillcolor=gray];
53 [label="Exit block" style="filled" fillcolor=gray]; 49 [label="Exit block" style="filled" fillcolor=gray];
} }
54 [label="Exit function closeFinally" style="filled" fillcolor=red]; 50 [label="Exit function closeFinally" style="filled" fillcolor=red];
} }
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9}; 8 -> {9};
9 -> {10}; 9 -> {10};
10 -> {11}; 10 -> {11};
11 -> {12}; 11 -> {42 12};
12 -> {13}; 12 -> {13};
13 -> {14}; 13 -> {14};
14 -> {15}; 14 -> {15};
15 -> {46 16}; 15 -> {16};
16 -> {17}; 16 -> {37 17};
17 -> {18}; 17 -> {18};
18 -> {19}; 18 -> {19};
19 -> {20}; 19 -> {20};
20 -> {41 21}; 20 -> {21};
21 -> {22}; 21 -> {22 27};
22 -> {23}; 22 -> {23};
23 -> {24}; 23 -> {24};
24 -> {25}; 24 -> {25};
25 -> {26 31}; 25 -> {26};
26 -> {27}; 26 -> {34 27};
27 -> {28}; 27 -> {28};
27 -> {50} [label=onUncaughtException];
28 -> {29}; 28 -> {29};
29 -> {30}; 29 -> {30};
30 -> {38 31}; 30 -> {31};
31 -> {32}; 31 -> {32};
31 -> {54} [label=onUncaughtException];
32 -> {33}; 32 -> {33};
33 -> {34}; 33 -> {34};
34 -> {35}; 34 -> {35};
35 -> {36}; 35 -> {36};
36 -> {37}; 36 -> {46};
37 -> {38}; 37 -> {38};
38 -> {39}; 38 -> {39};
39 -> {40}; 39 -> {40};
40 -> {50}; 40 -> {41};
41 -> {42}; 41 -> {46};
42 -> {43}; 42 -> {43};
43 -> {44}; 43 -> {44};
44 -> {45}; 44 -> {45};
45 -> {50}; 45 -> {46};
46 -> {47}; 46 -> {47};
47 -> {48}; 47 -> {50};
48 -> {49}; 47 -> {48} [style=dotted];
49 -> {50}; 48 -> {49} [style=dotted];
50 -> {51}; 49 -> {50} [style=dotted];
51 -> {54};
51 -> {52} [style=dotted];
52 -> {53} [style=dotted];
53 -> {54} [style=dotted];
subgraph cluster_18 { subgraph cluster_16 {
color=red color=red
55 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red]; 51 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red];
subgraph cluster_19 { subgraph cluster_17 {
color=blue color=blue
56 [label="Enter block"]; 52 [label="Enter block"];
subgraph cluster_20 { subgraph cluster_18 {
color=blue color=blue
57 [label="Enter block"]; 53 [label="Enter block"];
58 [label="Access variable this@R|/firstIsInstanceOrNull|"]; 54 [label="Access variable this@R|/firstIsInstanceOrNull|"];
59 [label="Function call: this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()"]; 55 [label="Function call: this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()"];
60 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"]; 56 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"];
subgraph cluster_21 { subgraph cluster_19 {
color=blue color=blue
61 [label="Enter while loop"]; 57 [label="Enter while loop"];
subgraph cluster_22 { subgraph cluster_20 {
color=blue color=blue
62 [label="Enter loop condition"]; 58 [label="Enter loop condition"];
63 [label="Access variable R|<local>/<iterator>|"]; 59 [label="Access variable R|<local>/<iterator>|"];
64 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()"]; 60 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()"];
65 [label="Exit loop condition"]; 61 [label="Exit loop condition"];
} }
subgraph cluster_23 { subgraph cluster_21 {
color=blue color=blue
66 [label="Enter loop block"]; 62 [label="Enter loop block"];
subgraph cluster_24 { subgraph cluster_22 {
color=blue color=blue
67 [label="Enter block"]; 63 [label="Enter block"];
68 [label="Access variable R|<local>/<iterator>|"]; 64 [label="Access variable R|<local>/<iterator>|"];
69 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()"]; 65 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()"];
70 [label="Variable declaration: lval element: R|kotlin/Any?|"]; 66 [label="Variable declaration: lval element: R|kotlin/Any?|"];
subgraph cluster_25 { subgraph cluster_23 {
color=blue color=blue
71 [label="Enter when"]; 67 [label="Enter when"];
subgraph cluster_26 { subgraph cluster_24 {
color=blue color=blue
72 [label="Enter when branch condition "]; 68 [label="Enter when branch condition "];
73 [label="Access variable R|<local>/element|"]; 69 [label="Access variable R|<local>/element|"];
74 [label="Type operator: (R|<local>/element| is R|T|)"]; 70 [label="Type operator: (R|<local>/element| is R|T|)"];
75 [label="Exit when branch condition"]; 71 [label="Exit when branch condition"];
} }
76 [label="Synthetic else branch"]; 72 [label="Synthetic else branch"];
77 [label="Enter when branch result"]; 73 [label="Enter when branch result"];
subgraph cluster_27 { subgraph cluster_25 {
color=blue color=blue
78 [label="Enter block"]; 74 [label="Enter block"];
79 [label="Access variable R|<local>/element|"]; 75 [label="Access variable R|<local>/element|"];
80 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"]; 76 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"];
81 [label="Stub" style="filled" fillcolor=gray]; 77 [label="Stub" style="filled" fillcolor=gray];
82 [label="Exit block" style="filled" fillcolor=gray]; 78 [label="Exit block" style="filled" fillcolor=gray];
} }
83 [label="Exit when branch result" style="filled" fillcolor=gray]; 79 [label="Exit when branch result" style="filled" fillcolor=gray];
84 [label="Exit when"]; 80 [label="Exit when"];
} }
85 [label="Exit block"]; 81 [label="Exit block"];
} }
86 [label="Exit loop block"]; 82 [label="Exit loop block"];
} }
87 [label="Exit whileloop"]; 83 [label="Exit whileloop"];
} }
88 [label="Exit block"]; 84 [label="Exit block"];
} }
89 [label="Const: Null(null)"]; 85 [label="Const: Null(null)"];
90 [label="Jump: ^firstIsInstanceOrNull Null(null)"]; 86 [label="Jump: ^firstIsInstanceOrNull Null(null)"];
91 [label="Stub" style="filled" fillcolor=gray]; 87 [label="Stub" style="filled" fillcolor=gray];
92 [label="Exit block" style="filled" fillcolor=gray]; 88 [label="Exit block" style="filled" fillcolor=gray];
} }
93 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red]; 89 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red];
} }
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56}; 55 -> {56};
56 -> {57}; 56 -> {57};
57 -> {58}; 57 -> {58};
58 -> {59}; 58 -> {59};
59 -> {60}; 59 -> {60};
60 -> {61}; 60 -> {61};
61 -> {62}; 61 -> {83 62};
62 -> {63}; 62 -> {63};
63 -> {64}; 63 -> {64};
64 -> {65}; 64 -> {65};
65 -> {87 66}; 65 -> {66};
66 -> {67}; 66 -> {67};
67 -> {68}; 67 -> {68};
68 -> {69}; 68 -> {69};
69 -> {70}; 69 -> {70};
70 -> {71}; 70 -> {71};
71 -> {72}; 71 -> {73 72};
72 -> {73}; 72 -> {80};
73 -> {74}; 73 -> {74};
74 -> {75}; 74 -> {75};
75 -> {77 76}; 75 -> {76};
76 -> {84}; 76 -> {89};
77 -> {78}; 76 -> {77} [style=dotted];
78 -> {79}; 77 -> {78} [style=dotted];
79 -> {80}; 78 -> {79} [style=dotted];
80 -> {93}; 79 -> {80} [style=dotted];
80 -> {81} [style=dotted]; 80 -> {81};
81 -> {82} [style=dotted]; 81 -> {82};
82 -> {83} [style=dotted]; 82 -> {58} [color=green style=dashed];
83 -> {84} [style=dotted]; 83 -> {84};
84 -> {85}; 84 -> {85};
85 -> {86}; 85 -> {86};
86 -> {62} [color=green style=dashed]; 86 -> {89};
87 -> {88}; 86 -> {87} [style=dotted];
88 -> {89}; 87 -> {88} [style=dotted];
89 -> {90}; 88 -> {89} [style=dotted];
90 -> {93};
90 -> {91} [style=dotted];
91 -> {92} [style=dotted];
92 -> {93} [style=dotted];
} }
@@ -2,8 +2,6 @@ FILE: complex.kt
public abstract interface AutoCloseable : R|kotlin/Any| { public abstract interface AutoCloseable : R|kotlin/Any| {
public abstract fun close(): R|kotlin/Unit| public abstract fun close(): R|kotlin/Unit|
}
public final fun R|kotlin/Throwable|.addSuppressed(other: R|kotlin/Throwable|): R|kotlin/Unit| {
} }
internal final fun R|AutoCloseable?|.closeFinally(cause: R|kotlin/Throwable?|): R|kotlin/Unit| { internal final fun R|AutoCloseable?|.closeFinally(cause: R|kotlin/Throwable?|): R|kotlin/Unit| {
^closeFinally when () { ^closeFinally when () {
@@ -17,7 +15,7 @@ FILE: complex.kt
this@R|/closeFinally|.R|/AutoCloseable.close|() this@R|/closeFinally|.R|/AutoCloseable.close|()
} }
catch (closeException: R|kotlin/Throwable|) { catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|/addSuppressed|(R|<local>/closeException|) R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(R|<local>/closeException|)
} }
} }
@@ -3,8 +3,6 @@ interface AutoCloseable {
fun close() fun close()
} }
fun Throwable.addSuppressed(other: Throwable) {}
internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when { internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when {
this == null -> {} this == null -> {}
cause == null -> close() cause == null -> close()
@@ -25721,6 +25721,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt"); runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt");
} }
@Test
@TestMetadata("memberWithHidesMemberAnnotationVsMemberWithout.kt")
public void testMemberWithHidesMemberAnnotationVsMemberWithout() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberWithHidesMemberAnnotationVsMemberWithout.kt");
}
@Test @Test
@TestMetadata("staticVsImplicitReceiverMember.kt") @TestMetadata("staticVsImplicitReceiverMember.kt")
public void testStaticVsImplicitReceiverMember() throws Exception { public void testStaticVsImplicitReceiverMember() throws Exception {
@@ -25721,6 +25721,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt"); runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt");
} }
@Test
@TestMetadata("memberWithHidesMemberAnnotationVsMemberWithout.kt")
public void testMemberWithHidesMemberAnnotationVsMemberWithout() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberWithHidesMemberAnnotationVsMemberWithout.kt");
}
@Test @Test
@TestMetadata("staticVsImplicitReceiverMember.kt") @TestMetadata("staticVsImplicitReceiverMember.kt")
public void testStaticVsImplicitReceiverMember() throws Exception { public void testStaticVsImplicitReceiverMember() throws Exception {
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
import org.jetbrains.kotlin.fir.declarations.getAnnotationByClassId
import org.jetbrains.kotlin.fir.declarations.utils.modality import org.jetbrains.kotlin.fir.declarations.utils.modality
import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.inference.ConeTypeParameterBasedTypeVariable import org.jetbrains.kotlin.fir.resolve.inference.ConeTypeParameterBasedTypeVariable
@@ -15,6 +16,7 @@ import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.HidesMembers
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
import org.jetbrains.kotlin.resolve.calls.results.FlatSignature import org.jetbrains.kotlin.resolve.calls.results.FlatSignature
@@ -43,7 +45,11 @@ class ConeOverloadConflictResolver(
candidates candidates
return chooseMaximallySpecificCandidates( return chooseMaximallySpecificCandidates(
fixedCandidates, discriminateGenerics, discriminateAbstracts, discriminateSAMs = true, discriminateSuspendConversions = true fixedCandidates,
discriminateGenerics,
discriminateAbstracts,
discriminateSAMs = true,
discriminateSuspendConversions = true
) )
} }
@@ -78,11 +78,11 @@ internal abstract class FirBaseTowerResolveTask(
protected fun FirScope.toScopeTowerLevel( protected fun FirScope.toScopeTowerLevel(
extensionReceiver: ReceiverValue? = null, extensionReceiver: ReceiverValue? = null,
extensionsOnly: Boolean = false, withHideMembersOnly: Boolean = false,
includeInnerConstructors: Boolean = extensionReceiver != null, includeInnerConstructors: Boolean = extensionReceiver != null,
): ScopeTowerLevel = ScopeTowerLevel( ): ScopeTowerLevel = ScopeTowerLevel(
session, components, this, session, components, this,
extensionReceiver, extensionsOnly, includeInnerConstructors extensionReceiver, withHideMembersOnly, includeInnerConstructors
) )
protected fun ReceiverValue.toMemberScopeTowerLevel( protected fun ReceiverValue.toMemberScopeTowerLevel(
@@ -386,12 +386,14 @@ internal open class FirTowerResolveTask(
depth: Int?, depth: Int?,
explicitReceiverKind: ExplicitReceiverKind, explicitReceiverKind: ExplicitReceiverKind,
parentGroup: TowerGroup parentGroup: TowerGroup
) = processLevel( ) {
topLevelScope.toScopeTowerLevel( processLevel(
extensionReceiver = receiverValue, extensionsOnly = true topLevelScope.toScopeTowerLevel(
), extensionReceiver = receiverValue, withHideMembersOnly = true
info, ),
parentGroup.TopPrioritized(index).let { if (depth != null) it.Implicit(depth) else it }, info,
explicitReceiverKind, parentGroup.TopPrioritized(index).let { if (depth != null) it.Implicit(depth) else it },
) explicitReceiverKind,
)
}
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls.tower
import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.getAnnotationByClassId
import org.jetbrains.kotlin.fir.declarations.utils.isInner import org.jetbrains.kotlin.fir.declarations.utils.isInner
import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
@@ -23,6 +24,7 @@ import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.HidesMembers
import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.SmartList
@@ -220,7 +222,7 @@ class ScopeTowerLevel(
private val bodyResolveComponents: BodyResolveComponents, private val bodyResolveComponents: BodyResolveComponents,
val scope: FirScope, val scope: FirScope,
val extensionReceiver: ReceiverValue?, val extensionReceiver: ReceiverValue?,
private val extensionsOnly: Boolean, private val withHideMembersOnly: Boolean,
private val includeInnerConstructors: Boolean private val includeInnerConstructors: Boolean
) : SessionBasedTowerLevel(session) { ) : SessionBasedTowerLevel(session) {
@@ -286,7 +288,10 @@ class ScopeTowerLevel(
processor: TowerScopeLevelProcessor<T> processor: TowerScopeLevelProcessor<T>
) { ) {
val candidateReceiverTypeRef = candidate.fir.receiverTypeRef val candidateReceiverTypeRef = candidate.fir.receiverTypeRef
val receiverExpected = extensionsOnly || extensionReceiver != null if (withHideMembersOnly && candidate.getAnnotationByClassId(HidesMembers) == null) {
return
}
val receiverExpected = withHideMembersOnly || extensionReceiver != null
if (candidateReceiverTypeRef == null == receiverExpected) return if (candidateReceiverTypeRef == null == receiverExpected) return
val dispatchReceiverValue = dispatchReceiverValue(candidate) val dispatchReceiverValue = dispatchReceiverValue(candidate)
if (dispatchReceiverValue == null && shouldSkipCandidateWithInconsistentExtensionReceiver(candidate)) { if (dispatchReceiverValue == null && shouldSkipCandidateWithInconsistentExtensionReceiver(candidate)) {
@@ -0,0 +1,12 @@
// FIR_IDENTICAL
// WITH_STDLIB
// ISSUE: KT-50776
interface Entities<Target> : MutableCollection<Target>, Sequence<Target>
abstract class StringEntities : Entities<String> {
fun foo() {
forEach {
println(it)
}
}
}
@@ -0,0 +1,37 @@
package
public interface Entities</*0*/ Target> : kotlin.collections.MutableCollection<Target>, kotlin.sequences.Sequence<Target> {
public abstract override /*1*/ /*fake_override*/ val size: kotlin.Int
public abstract override /*1*/ /*fake_override*/ fun add(/*0*/ element: Target): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun addAll(/*0*/ elements: kotlin.collections.Collection<Target>): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit
public abstract override /*1*/ /*fake_override*/ fun contains(/*0*/ element: Target): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun containsAll(/*0*/ elements: kotlin.collections.Collection<Target>): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean
public abstract override /*2*/ /*fake_override*/ fun iterator(): kotlin.collections.MutableIterator<Target>
public abstract override /*1*/ /*fake_override*/ fun remove(/*0*/ element: Target): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun removeAll(/*0*/ elements: kotlin.collections.Collection<Target>): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun retainAll(/*0*/ elements: kotlin.collections.Collection<Target>): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
public abstract class StringEntities : Entities<kotlin.String> {
public constructor StringEntities()
public abstract override /*1*/ /*fake_override*/ val size: kotlin.Int
public abstract override /*1*/ /*fake_override*/ fun add(/*0*/ element: kotlin.String): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun addAll(/*0*/ elements: kotlin.collections.Collection<kotlin.String>): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit
public abstract override /*1*/ /*fake_override*/ fun contains(/*0*/ element: kotlin.String): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun containsAll(/*0*/ elements: kotlin.collections.Collection<kotlin.String>): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun iterator(): kotlin.collections.MutableIterator<kotlin.String>
public abstract override /*1*/ /*fake_override*/ fun remove(/*0*/ element: kotlin.String): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun removeAll(/*0*/ elements: kotlin.collections.Collection<kotlin.String>): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun retainAll(/*0*/ elements: kotlin.collections.Collection<kotlin.String>): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -25733,6 +25733,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt"); runTest("compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt");
} }
@Test
@TestMetadata("memberWithHidesMemberAnnotationVsMemberWithout.kt")
public void testMemberWithHidesMemberAnnotationVsMemberWithout() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/priority/memberWithHidesMemberAnnotationVsMemberWithout.kt");
}
@Test @Test
@TestMetadata("staticVsImplicitReceiverMember.kt") @TestMetadata("staticVsImplicitReceiverMember.kt")
public void testStaticVsImplicitReceiverMember() throws Exception { public void testStaticVsImplicitReceiverMember() throws Exception {
@@ -142,6 +142,8 @@ object StandardClassIds {
val Deprecated = "Deprecated".baseId() val Deprecated = "Deprecated".baseId()
val DeprecatedSinceKotlin = "DeprecatedSinceKotlin".baseId() val DeprecatedSinceKotlin = "DeprecatedSinceKotlin".baseId()
val HidesMembers = "HidesMembers".internalId()
val Retention = "Retention".annotationId() val Retention = "Retention".annotationId()
val Target = "Target".annotationId() val Target = "Target".annotationId()
val Repeatable = "Repeatable".annotationId() val Repeatable = "Repeatable".annotationId()