From 1d69f35f273c2be0931852c3dc7c1d5c739e526f Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 12 Dec 2018 17:28:51 +0300 Subject: [PATCH] Revert "[NI] Take into account captured types for type depth computation" This reverts commit 383c2d1bff0770b23e4c8a465bcde204b0446b7e. It seems this commit causes problems with bootstraping, so it'll be investigated and refined later --- .../kotlin/types/TypeApproximator.kt | 3 -- .../generics/capturingOfDeepNestedType.kt | 36 ------------------- .../generics/capturingOfDeepNestedType.txt | 13 ------- .../checkers/DiagnosticsTestGenerated.java | 5 --- .../DiagnosticsUsingJavacTestGenerated.java | 5 --- 5 files changed, 62 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.kt delete mode 100644 compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.txt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt b/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt index 17412b2ded0..9f82cb0a48a 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt @@ -470,9 +470,6 @@ internal fun UnwrappedType.typeDepth() = internal fun SimpleType.typeDepth(): Int { if (this is TypeUtils.SpecialType) return 0 - if (this is NewCapturedType) { - return constructor.projection.type.unwrap().typeDepth() - } val maxInArguments = arguments.asSequence().map { if (it.isStarProjection) 1 else it.type.unwrap().typeDepth() diff --git a/compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.kt b/compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.kt deleted file mode 100644 index 7088456f9f2..00000000000 --- a/compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.kt +++ /dev/null @@ -1,36 +0,0 @@ -// !LANGUAGE: +NewInference -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER - -class Inv(val x: T) - -fun case_1(a: Inv?>?>?>?>?>?) { - if (a != null) { - val b: Inv?>?>?>?>? = a.x - } -} - -fun case_2(a: Inv?>?>?>?>?>?) { - if (a != null) { - val b: Inv?>?>?>?>? = a.x - if (b != null) { - val c = b.x - if (c != null) { - val d = c.x - if (d != null) { - val e = d.x - if (e != null) { - val f = e.x - if (f != null) { - val g = f.x - if (g != null) { - takeInt(g) - } - } - } - } - } - } - } -} - -fun takeInt(i: Int) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.txt b/compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.txt deleted file mode 100644 index 662437d13bb..00000000000 --- a/compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun case_1(/*0*/ a: Inv?>?>?>?>?>?): kotlin.Unit -public fun case_2(/*0*/ a: Inv?>?>?>?>?>?): kotlin.Unit -public fun takeInt(/*0*/ i: kotlin.Int): kotlin.Unit - -public final class Inv { - public constructor Inv(/*0*/ x: T) - public final val x: T - 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 -} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 31d7bdb27e6..7ec55f41c0a 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -7948,11 +7948,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt"); } - @TestMetadata("capturingOfDeepNestedType.kt") - public void testCapturingOfDeepNestedType() throws Exception { - runTest("compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.kt"); - } - @TestMetadata("commonSupertypeContravariant.kt") public void testCommonSupertypeContravariant() throws Exception { runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 3186664f1ea..d8e8fb8ade1 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -7948,11 +7948,6 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt"); } - @TestMetadata("capturingOfDeepNestedType.kt") - public void testCapturingOfDeepNestedType() throws Exception { - runTest("compiler/testData/diagnostics/tests/generics/capturingOfDeepNestedType.kt"); - } - @TestMetadata("commonSupertypeContravariant.kt") public void testCommonSupertypeContravariant() throws Exception { runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");