Remake KotlinTypes.

This commit is contained in:
Stanislav Erokhin
2016-06-03 18:45:41 +03:00
parent 56122460aa
commit 1d9ca06b96
40 changed files with 283 additions and 523 deletions
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.serialization.SerializerExtension;
import org.jetbrains.kotlin.serialization.StringTable;
import org.jetbrains.kotlin.serialization.jvm.ClassMapperLite;
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf;
import org.jetbrains.kotlin.types.DelegatingFlexibleType;
import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.Method;
@@ -84,7 +84,7 @@ public class JvmSerializerExtension extends SerializerExtension {
@Override
public void serializeFlexibleType(
@NotNull DelegatingFlexibleType flexibleType,
@NotNull FlexibleType flexibleType,
@NotNull ProtoBuf.Type.Builder lowerProto,
@NotNull ProtoBuf.Type.Builder upperProto
) {
@@ -94,12 +94,12 @@ public class PossiblyBareType {
KotlinType nullableActualType = TypeUtils.makeNullable(getActualType());
KotlinType abbreviatedType = KotlinTypeKt.getAbbreviatedType(getActualType());
KotlinType abbreviatedType = SpecialTypesKt.getAbbreviatedType(getActualType());
if (abbreviatedType == null) {
return type(nullableActualType);
}
else {
return type(KotlinTypeKt.withAbbreviatedType(KotlinTypeKt.asSimpleType(nullableActualType), KotlinTypeKt.asSimpleType(TypeUtils.makeNullable(abbreviatedType))));
return type(SpecialTypesKt.withAbbreviatedType(KotlinTypeKt.asSimpleType(nullableActualType), KotlinTypeKt.asSimpleType(TypeUtils.makeNullable(abbreviatedType))));
}
}
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier
import org.jetbrains.kotlin.resolve.source.toSourceElement
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.storage.getValue
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.Variance.*
import org.jetbrains.kotlin.types.typeUtil.isArrayOfNothing
@@ -102,7 +103,7 @@ class TypeResolver(
class LazyKotlinType : WrappedType(), LazyEntity {
private val _delegate = storageManager.createLazyValue { doResolvePossiblyBareType(c, typeReference).getActualType() }
override fun unwrap() = _delegate()
override val delegate: KotlinType by _delegate
override fun isComputed() = _delegate.isComputed()
override fun forceResolveAllContents() {
@@ -88,7 +88,7 @@ public class DeferredType extends WrappedType implements LazyType {
@NotNull
@Override
public KotlinType unwrap() {
public KotlinType getDelegate() {
return lazyValue.invoke();
}
@@ -506,7 +506,7 @@ public class DescriptorSerializer {
}
if (FlexibleTypesKt.isFlexible(type)) {
DelegatingFlexibleType flexibleType = (DelegatingFlexibleType) FlexibleTypesKt.asFlexibleType(type);
FlexibleType flexibleType = FlexibleTypesKt.asFlexibleType(type);
ProtoBuf.Type.Builder lowerBound = type(flexibleType.getLowerBound());
ProtoBuf.Type.Builder upperBound = type(flexibleType.getUpperBound());
@@ -548,7 +548,7 @@ public class DescriptorSerializer {
builder.setNullable(type.isMarkedNullable());
}
KotlinType abbreviatedType = KotlinTypeKt.getAbbreviatedType(type);
KotlinType abbreviatedType = SpecialTypesKt.getAbbreviatedType(type);
if (abbreviatedType != null) {
if (useTypeTable()) {
builder.setAbbreviatedTypeId(typeId(abbreviatedType));
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.serialization;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.types.DelegatingFlexibleType;
import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.KotlinType;
public abstract class SerializerExtension {
@@ -50,7 +50,7 @@ public abstract class SerializerExtension {
public void serializeValueParameter(@NotNull ValueParameterDescriptor descriptor, @NotNull ProtoBuf.ValueParameter.Builder proto) {
}
public void serializeFlexibleType(@NotNull DelegatingFlexibleType flexibleType, @NotNull ProtoBuf.Type.Builder lowerProto, @NotNull ProtoBuf.Type.Builder upperProto) {
public void serializeFlexibleType(@NotNull FlexibleType flexibleType, @NotNull ProtoBuf.Type.Builder lowerProto, @NotNull ProtoBuf.Type.Builder upperProto) {
}
public void serializeType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder proto) {
@@ -9,5 +9,5 @@ Resolved call:
Resulting descriptor: fun foo(): dynamic defined in bar
Explicit receiver kind = DISPATCH_RECEIVER
Dispatch receiver = a {('Nothing'..'Any?')}
Dispatch receiver = a {dynamic}
Extension receiver = NO_RECEIVER
@@ -12,4 +12,4 @@ Resulting descriptor: fun dynamic.foo(): Unit defined in root package
Explicit receiver kind = EXTENSION_RECEIVER
Dispatch receiver = NO_RECEIVER
Extension receiver = a {('Nothing'..'Any?')}
Extension receiver = a {dynamic}
@@ -16,4 +16,4 @@ Resulting descriptor: fun dynamic.foo(): Unit defined in A
Explicit receiver kind = EXTENSION_RECEIVER
Dispatch receiver = AExt{fun A.<anonymous>(): Unit defined in bar}
Extension receiver = b {('Nothing'..'Any?')}
Extension receiver = b {dynamic}
@@ -18,4 +18,4 @@ Resulting descriptor: fun dynamic.foo(): Unit defined in A
Explicit receiver kind = NO_EXPLICIT_RECEIVER
Dispatch receiver = AExt{fun A.<anonymous>(): Unit defined in bar}
Extension receiver = ('Nothing'..'Any?')Ext{fun dynamic.<anonymous>(): Unit defined in bar.<anonymous>}
Extension receiver = dynamicExt{fun dynamic.<anonymous>(): Unit defined in bar.<anonymous>}
@@ -9,5 +9,5 @@ Resolved call:
Resulting descriptor: fun foo(): dynamic defined in bar
Explicit receiver kind = NO_EXPLICIT_RECEIVER
Dispatch receiver = ('Nothing'..'Any?')Ext{fun dynamic.bar(): Unit defined in root package}
Dispatch receiver = dynamicExt{fun dynamic.bar(): Unit defined in root package}
Extension receiver = NO_RECEIVER
@@ -12,4 +12,4 @@ Resulting descriptor: fun dynamic.foo(): Unit defined in root package
Explicit receiver kind = NO_EXPLICIT_RECEIVER
Dispatch receiver = NO_RECEIVER
Extension receiver = ('Nothing'..'Any?')Ext{fun dynamic.bar(): Unit defined in root package}
Extension receiver = dynamicExt{fun dynamic.bar(): Unit defined in root package}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* 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.
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase;
import org.jetbrains.kotlin.types.DelegatingFlexibleType;
import org.jetbrains.kotlin.types.FlexibleTypeImpl;
public abstract class KotlinTestWithEnvironmentManagement extends KtUsefulTestCase {
static {
System.setProperty("java.awt.headless", "true");
DelegatingFlexibleType.RUN_SLOW_ASSERTIONS = true;
FlexibleTypeImpl.RUN_SLOW_ASSERTIONS = true;
}
@NotNull
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
import org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.KotlinTypeImpl
import org.jetbrains.kotlin.utils.Printer
import java.lang.reflect.Constructor
import java.lang.reflect.GenericDeclaration
@@ -177,7 +176,7 @@ class LazyOperationsLog(
o.joinTo(sb, ", ", prefix = "{", postfix = "}", limit = 3) { render(it) }
}
}
o is KotlinTypeImpl -> {
o is KotlinType -> {
StringBuilder().apply {
append(o.constructor)
if (!o.arguments.isEmpty()) {