From fd40273a0db837a2603f301a87ebb11add05748a Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Sat, 4 Jun 2016 03:01:48 +0300 Subject: [PATCH] Removed interface LazyType. --- .../jetbrains/kotlin/types/DeferredType.java | 2 +- ...VariableDescriptorWithInitializerImpl.java | 3 +-- .../kotlin/renderer/DescriptorRendererImpl.kt | 4 ++-- .../kotlin/resolve/DescriptorUtils.java | 4 ++-- .../org/jetbrains/kotlin/types/KotlinType.kt | 2 +- .../org/jetbrains/kotlin/types/LazyType.java | 20 ------------------- 6 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java b/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java index 8e686867d99..57a88697613 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException; import static org.jetbrains.kotlin.resolve.BindingContext.DEFERRED_TYPE; -public class DeferredType extends WrappedType implements LazyType { +public class DeferredType extends WrappedType { private static final Function1 EMPTY_CONSUMER = new Function1() { @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java index 41eab86f85f..bcb5cdfb52d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.storage.NullableLazyValue; import org.jetbrains.kotlin.types.KotlinType; -import org.jetbrains.kotlin.types.LazyType; public abstract class VariableDescriptorWithInitializerImpl extends VariableDescriptorImpl { private final boolean isVar; @@ -54,7 +53,7 @@ public abstract class VariableDescriptorWithInitializerImpl extends VariableDesc @Override public ConstantValue getCompileTimeInitializer() { // Force computation and setting of compileTimeInitializer, if needed - if (compileTimeInitializer == null && outType instanceof LazyType) { + if (compileTimeInitializer == null) { outType.getConstructor(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index b1ded33e6b0..8b324c78507 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -136,8 +136,8 @@ internal class DescriptorRendererImpl( } private fun renderNormalizedTypeAsIs(type: KotlinType): String { - if (type is LazyType && debugMode) { - return type.toString() + if (type is WrappedType && debugMode && !type.isComputed()) { + return "" } val unwrappedType = type.unwrap() return when (unwrappedType) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index c0ee7838fc3..da070d41493 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -35,8 +35,8 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter; import org.jetbrains.kotlin.resolve.scopes.MemberScope; import org.jetbrains.kotlin.types.ErrorUtils; import org.jetbrains.kotlin.types.KotlinType; -import org.jetbrains.kotlin.types.LazyType; import org.jetbrains.kotlin.types.TypeConstructor; +import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.*; @@ -450,7 +450,7 @@ public class DescriptorUtils { public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KotlinType type) { if (variable.isVar() || type.isError()) return false; - if (type instanceof LazyType || type.isMarkedNullable()) return true; + if (TypeUtils.acceptsNullable(type)) return true; KotlinBuiltIns builtIns = getBuiltIns(variable); return KotlinBuiltIns.isPrimitiveType(type) || diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt index 20fce9ce417..56300d89955 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt @@ -55,7 +55,7 @@ sealed class KotlinType : Annotated { } } -abstract class WrappedType() : KotlinType(), LazyType { +abstract class WrappedType() : KotlinType() { open fun isComputed(): Boolean = true protected abstract val delegate: KotlinType diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java b/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java deleted file mode 100644 index 3a4d19fdc31..00000000000 --- a/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.types; - -public interface LazyType { -}