Merge branch 'master' into rr/yole/kdoc-generate

This commit is contained in:
Dmitry Jemerov
2015-01-21 18:00:21 +01:00
12 changed files with 93 additions and 22 deletions
+9 -3
View File
@@ -77,7 +77,9 @@
<pathelement location="${idea.sdk}/lib/javac2.jar"/>
<pathelement location="${idea.sdk}/lib/asm-all.jar"/>
</path>
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath" loaderref="javac2.loader"/>
<typedef name="skip" classname="com.intellij.ant.ClassFilterAnnotationRegexp" classpathref="javac2.classpath"
loaderref="javac2.loader"/>
<echo message="Use javac2 from Idea lib"/>
</then>
<else>
@@ -368,10 +370,10 @@
<target name="preloader">
<cleandir dir="${output}/classes/preloader"/>
<javac2 destdir="${output}/classes/preloader" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
<javac destdir="${output}/classes/preloader" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<src refid="preloaderSources.path"/>
</javac2>
</javac>
<jar jarfile="${kotlin-home}/lib/kotlin-preloader.jar">
<fileset dir="${output}/classes/preloader"/>
@@ -468,6 +470,7 @@
<javac2 destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<skip pattern="kotlin/jvm/internal/.*"/>
<src refid="compilerSources.path"/>
<classpath refid="classpath"/>
</javac2>
@@ -620,6 +623,7 @@
<javac2 destdir="${output}/classes/ant" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<skip pattern="kotlin/jvm/internal/.*"/>
<src>
<dirset dir="${basedir}/ant">
<include name="src"/>
@@ -711,6 +715,7 @@
<then>
<javac2 srcdir="${src.paths}" destdir="@{output}" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<skip pattern="kotlin/jvm/internal/.*"/>
<classpath>
<path refid="classpath.path"/>
<!-- Include @{output} here for Java compiler to resolve symbols from Kotlin sources -->
@@ -863,6 +868,7 @@
<javac2 destdir="${output}/classes/idea-analysis" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<skip pattern="kotlin/jvm/internal/.*"/>
<src>
<dirset dir="${basedir}/idea/ide-common" includes="src"/>
<dirset dir="${basedir}/idea/idea-analysis" includes="src"/>
@@ -39,11 +39,6 @@ public class FunctionDescriptorUtil {
return null;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public String toString() {
return "FunctionDescriptorUtil.MAKE_TYPE_PARAMETERS_FRESH";
@@ -0,0 +1,7 @@
class Bar
fun Bar.foo() = 42
object MyObject {
fun foo(bar: Bar) = bar.foo()
}
@@ -0,0 +1,26 @@
package
internal fun Bar.foo(): kotlin.Int
internal final class Bar {
public constructor Bar()
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
}
internal object MyObject {
private constructor MyObject()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal final fun foo(/*0*/ bar: Bar): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public class object <class-object-for-MyObject> : MyObject {
private constructor <class-object-for-MyObject>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal final override /*1*/ /*fake_override*/ fun foo(/*0*/ bar: Bar): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -5208,6 +5208,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("notApproximateWhenCopyDescriptors.kt")
public void testNotApproximateWhenCopyDescriptors() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/notApproximateWhenCopyDescriptors.kt");
doTest(fileName);
}
@TestMetadata("overApproximationForInCaptured.kt")
public void testOverApproximationForInCaptured() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt");
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundC
import org.jetbrains.kotlin.types.getCustomTypeVariable
import org.jetbrains.kotlin.types.isFlexible
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound
import org.jetbrains.kotlin.types.TypeSubstitution
public class ConstraintSystemImpl : ConstraintSystem {
@@ -437,9 +438,9 @@ public class ConstraintSystemImpl : ConstraintSystem {
return if (typeParameterDescriptor != null && isMyTypeVariable(typeParameterDescriptor)) typeParameterDescriptor else null
}
override fun getResultingSubstitutor() = replaceUninferredBySpecialErrorType()
override fun getResultingSubstitutor() = replaceUninferredBySpecialErrorType().setApproximateCapturedTypes()
override fun getCurrentSubstitutor() = replaceUninferredBy(TypeUtils.DONT_CARE)
override fun getCurrentSubstitutor() = replaceUninferredBy(TypeUtils.DONT_CARE).setApproximateCapturedTypes()
private fun createCorrespondingExtensionFunctionType(functionType: JetType, receiverType: JetType): JetType {
assert(KotlinBuiltIns.isFunctionType(functionType))
@@ -461,3 +462,13 @@ public class ConstraintSystemImpl : ConstraintSystem {
return KotlinBuiltIns.getInstance().getFunctionType(functionType.getAnnotations(), receiverType, arguments, returnType)
}
}
private fun TypeSubstitutor.setApproximateCapturedTypes(): TypeSubstitutor {
return TypeSubstitutor.create(SubstitutionWithCapturedTypeApproximation(getSubstitution()))
}
private class SubstitutionWithCapturedTypeApproximation(val substitution: TypeSubstitution) : TypeSubstitution() {
override fun get(key: TypeConstructor?) = substitution[key]
override fun isEmpty() = substitution.isEmpty()
override fun approximateCapturedTypes() = true
}
@@ -74,8 +74,6 @@ public fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?):
if (typeProjection == null) return null
val type = typeProjection.getType()
//todo temporary hack to compile 'kotlin'
if (type is LazyType) return typeProjection
if (!TypeUtils.containsSpecialType(type, { it.isCaptured() })) {
return typeProjection
}
@@ -89,11 +87,10 @@ public fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?):
}
private fun substituteCapturedTypes(typeProjection: TypeProjection): TypeProjection? {
val typeSubstitutor = TypeSubstitutor.create(object : TypeSubstitution {
val typeSubstitutor = TypeSubstitutor.create(object : TypeSubstitution() {
override fun get(typeConstructor: TypeConstructor?): TypeProjection? {
return (typeConstructor as? CapturedTypeConstructor)?.typeProjection
}
override fun isEmpty() = false
})
return typeSubstitutor.substituteWithoutApproximation(typeProjection)
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.types;
import org.jetbrains.annotations.NotNull;
public class CompositeTypeSubstitution implements TypeSubstitution {
public class CompositeTypeSubstitution extends TypeSubstitution {
private final TypeSubstitution[] inner;
public CompositeTypeSubstitution(@NotNull TypeSubstitution... inner) {
@@ -42,6 +42,14 @@ public class CompositeTypeSubstitution implements TypeSubstitution {
return true;
}
@Override
public boolean approximateCapturedTypes() {
for (TypeSubstitution substitution : inner) {
if (substitution.approximateCapturedTypes()) return true;
}
return false;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -53,6 +53,11 @@ public class DescriptorSubstitutor {
return originalSubstitutor.isEmpty() && mutableSubstitution.isEmpty();
}
@Override
public boolean approximateCapturedTypes() {
return originalSubstitutor.getSubstitution().approximateCapturedTypes();
}
@Override
public String toString() {
return "DescriptorSubstitutor.substituteTypeParameters(" + mutableSubstitution + " / " + originalSubstitutor.getSubstitution() + ")";
@@ -18,8 +18,8 @@ package org.jetbrains.kotlin.types;
import org.jetbrains.annotations.Nullable;
public interface TypeSubstitution {
TypeSubstitution EMPTY = new TypeSubstitution() {
public abstract class TypeSubstitution {
public static final TypeSubstitution EMPTY = new TypeSubstitution() {
@Override
public TypeProjection get(TypeConstructor key) {
return null;
@@ -37,6 +37,13 @@ public interface TypeSubstitution {
};
@Nullable
TypeProjection get(TypeConstructor key);
boolean isEmpty();
public abstract TypeProjection get(TypeConstructor key);
public boolean isEmpty() {
return false;
}
public boolean approximateCapturedTypes() {
return false;
}
}
@@ -31,7 +31,7 @@ public class TypeSubstitutor {
private static final int MAX_RECURSION_DEPTH = 100;
public static class MapToTypeSubstitutionAdapter implements TypeSubstitution {
public static class MapToTypeSubstitutionAdapter extends TypeSubstitution {
private final @NotNull Map<TypeConstructor, TypeProjection> substitutionContext;
public MapToTypeSubstitutionAdapter(@NotNull Map<TypeConstructor, TypeProjection> substitutionContext) {
@@ -142,6 +142,9 @@ public class TypeSubstitutor {
@Nullable
public TypeProjection substitute(@NotNull TypeProjection typeProjection) {
TypeProjection substitutedTypeProjection = substituteWithoutApproximation(typeProjection);
if (!substitution.approximateCapturedTypes()) {
return substitutedTypeProjection;
}
return TypesApproximationPackage.approximateCapturedTypesIfNecessary(substitutedTypeProjection);
}
+2 -2
View File
@@ -23,13 +23,13 @@
<target name="update" depends="fetch-third-party,fetch-annotations" description="Update dependencies from public server">
<execute_update_with_id_resolve
teamcity.server.url="https://teamcity.jetbrains.com"
build.locator.request="buildType:bt410,status:SUCCESS,lookupLimit:1,branch:idea/${ideaVersion}"/>
build.locator.request="buildType:bt410,status:SUCCESS,branch:idea/${ideaVersion}"/>
</target>
<target name="jb_update" depends="fetch-third-party,fetch-annotations" description="Update dependencies from internal server">
<execute_update_with_id_resolve
teamcity.server.url="http://buildserver.labs.intellij.net"
build.locator.request="buildType:bt3498,status:SUCCESS,lookupLimit:1,branch:/idea/${ideaVersion}"/>
build.locator.request="buildType:bt3498,status:SUCCESS,branch:/idea/${ideaVersion}"/>
</target>
<target name="jb_update_continuous_139" depends="fetch-third-party,fetch-annotations">