diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index 188bade8b44..5a1623eb7ab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -237,7 +237,7 @@ class DeclarationsChecker( private fun checkTypeAliasExpansion(declaration: KtTypeAlias, typeAliasDescriptor: TypeAliasDescriptor) { val typeAliasExpansion = TypeAliasExpansion.createWithFormalArguments(typeAliasDescriptor) val reportStrategy = TypeAliasDeclarationCheckingReportStrategy(trace, typeAliasDescriptor, declaration) - TypeAliasExpander(reportStrategy).expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY) + TypeAliasExpander(reportStrategy, true).expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY) } private fun checkConstructorDeclaration(constructorDescriptor: ClassConstructorDescriptor, declaration: KtConstructor<*>) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt index 8a932bb1297..a8723e24171 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeAliasExpander.kt @@ -26,8 +26,10 @@ import org.jetbrains.kotlin.types.typeUtil.containsTypeAliasParameters import org.jetbrains.kotlin.types.typeUtil.requiresTypeAliasExpansion class TypeAliasExpander( - private val reportStrategy: TypeAliasExpansionReportStrategy + private val reportStrategy: TypeAliasExpansionReportStrategy, + private val shouldCheckBounds: Boolean ) { + fun expand(typeAliasExpansion: TypeAliasExpansion, annotations: Annotations) = expandRecursively(typeAliasExpansion, annotations, isNullable = false, recursionDepth = 0, withAbbreviatedType = true) @@ -228,7 +230,9 @@ class TypeAliasExpander( if (!substitutedArgument.isStarProjection && !substitutedArgument.type.containsTypeAliasParameters()) { val unsubstitutedArgument = unsubstitutedType.arguments[i] val typeParameter = unsubstitutedType.constructor.parameters[i] - DescriptorResolver.checkBoundsInTypeAlias(reportStrategy, unsubstitutedArgument.type, substitutedArgument.type, typeParameter, typeSubstitutor) + if (shouldCheckBounds) { + DescriptorResolver.checkBoundsInTypeAlias(reportStrategy, unsubstitutedArgument.type, substitutedArgument.type, typeParameter, typeSubstitutor) + } } } } @@ -242,6 +246,6 @@ class TypeAliasExpander( } } - val NON_REPORTING = TypeAliasExpander(TypeAliasExpansionReportStrategy.DO_NOTHING) + val NON_REPORTING = TypeAliasExpander(TypeAliasExpansionReportStrategy.DO_NOTHING, false) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 11be0da109f..a0eea798d74 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -544,7 +544,7 @@ class TypeResolver( } else { val typeAliasExpansion = TypeAliasExpansion.create(null, descriptor, arguments) - val expandedType = TypeAliasExpander(reportStrategy).expand(typeAliasExpansion, annotations) + val expandedType = TypeAliasExpander(reportStrategy, c.checkBounds).expand(typeAliasExpansion, annotations) type(expandedType) } } diff --git a/compiler/testData/diagnostics/tests/typealias/kt19601.kt b/compiler/testData/diagnostics/tests/typealias/kt19601.kt new file mode 100644 index 00000000000..3347ed4e3db --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/kt19601.kt @@ -0,0 +1,11 @@ +interface Order + +typealias Ord = Order + +class Test1> + +interface Num + +typealias N = Num + +class Test2String>> \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/kt19601.txt b/compiler/testData/diagnostics/tests/typealias/kt19601.txt new file mode 100644 index 00000000000..46f3e11cfdd --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/kt19601.txt @@ -0,0 +1,29 @@ +package + +public interface Num { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Order { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Test1 /* = Order */> { + public constructor Test1 /* = Order */>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Test2 /* = Num */> { + public constructor Test2 /* = Num */>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} +public typealias N = Num +public typealias Ord = Order diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 22d40f51c8f..17497caf643 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -22849,6 +22849,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt19601.kt") + public void testKt19601() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/kt19601.kt"); + doTest(fileName); + } + @TestMetadata("localTypeAlias.kt") public void testLocalTypeAlias() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/localTypeAlias.kt");