Compare commits

...

76 Commits

Author SHA1 Message Date
Yan Zhulanow
c9e43fdf97 Cast findViewById() result to Views safely
(cherry picked from commit 311b3cc)
2015-03-27 01:27:45 +03:00
Yan Zhulanow
68892e7ce1 Add imports for XML widget tags, support.v4 fake package files
(cherry picked from commit f7400d9)
2015-03-27 01:27:44 +03:00
Yan Zhulanow
e35c717ce6 Escape widget ids which are Kotlin keywords
(cherry picked from commit f0a0d36)
2015-03-27 01:27:44 +03:00
Yan Zhulanow
1c987ccf06 Ignore some XML tags
(cherry picked from commit b7ce63e)
2015-03-27 01:27:43 +03:00
Yan Zhulanow
1deca28673 Search for all properties in layout files corresponding to the given JetProperty
(cherry picked from commit 442a469)
2015-03-27 01:27:42 +03:00
Yan Zhulanow
a6ed69ff6d Fix Android byte code generation inside complex expressions
(cherry picked from commit 345c34e)
2015-03-27 01:27:41 +03:00
Yan Zhulanow
d31b80bf97 Clear layout cache on layout XML file add/remove
(cherry picked from commit 4adb7aa)
2015-03-27 01:27:41 +03:00
Yan Zhulanow
6633f00d2f Fix null-related warnings in AndroidRenameProcessor
(cherry picked from commit bbf9213)
2015-03-27 01:27:40 +03:00
Yan Zhulanow
fc8dd0fb9d Fix deprecated Kotlin constructs and remove unused code in Android plugins
(cherry picked from commit 3ab1e04)
2015-03-27 01:27:40 +03:00
Yan Zhulanow
3b6f3e4588 Simplify Module resolving in AndroidRenameProcessor
(cherry picked from commit 369bb78)
2015-03-27 01:27:39 +03:00
Yan Zhulanow
aee258a511 Generate synthetic packages even for layouts without @+id/ attributes declared
(cherry picked from commit 8df0292)
2015-03-27 01:27:38 +03:00
Yan Zhulanow
e20406fb48 Lookup XML attribute using the property (for a particular layout)
(cherry picked from commit 7fa8a98)
2015-03-27 01:27:38 +03:00
Yan Zhulanow
d52787cd48 Fix Android layout widget redeclarations
(cherry picked from commit edc2594)
2015-03-27 01:27:37 +03:00
Yan Zhulanow
cd4c4685eb Do not cast findViewById to View
(cherry picked from commit 2aba0a5)
2015-03-27 01:27:36 +03:00
Yan Zhulanow
2a20193227 Support special Android layout XML tags: fragment, include, merge
(cherry picked from commit ac3b978)
2015-03-27 01:27:36 +03:00
Alexey Sedunov
daedbc9c15 Extract Function: Do not extract extension function reference as parameter
(cherry picked from commit dcfefb0)
2015-03-26 23:14:13 +03:00
Alexey Sedunov
4010fcad4b Parser: Do not produce JetQualifiedExpression without receiver
#KT-7122 Fixed
(cherry picked from commit 4ec1b99)
2015-03-26 23:14:06 +03:00
Denis Zharkov
382029739a Minor, Rename isEmpty -> isImplicit 2015-03-26 22:10:20 +03:00
Denis Zharkov
9ba4aff807 Change contract of getDelegationCall to @NotNull
Its existence guaranteed by parser
2015-03-26 22:10:20 +03:00
Denis Zharkov
8d15418c0d Refine recovery for constructors 2015-03-26 22:10:20 +03:00
Denis Zharkov
c64f5ca9ed Add quickfixes inserting explicit delegation calls
#KT-6963 Fixed
2015-03-26 22:10:20 +03:00
Denis Zharkov
e0a70db2ff Mark value arguments in case of empty delegation call
It's useful for quickfixes for these diagnostics
2015-03-26 22:10:20 +03:00
Denis Zharkov
43bf23a69c Minor, always report diagnostics on callee expression
As these kinds of diagnostic always have non-empty callee expression
2015-03-26 22:10:20 +03:00
Denis Zharkov
e653fc7598 Minor, move isEmpty, isCallToThis to JetConstructorDelegationCall 2015-03-26 22:10:19 +03:00
Denis Zharkov
b99fb1dac3 Do not try to detect cycles if delegation call resolution is unsuccessful 2015-03-26 22:10:19 +03:00
Denis Zharkov
adbfadd7e5 Check if element is valid before checking it's writable
Otherwise it may lead to exception
2015-03-26 22:10:19 +03:00
Denis Zharkov
f3ece0bd4a Unify reporting resolution errors for empty delegation calls
- Always report "There is no applicable constructor for call without arguments in superclass"
  under `constructor` keyword by replacing default TracingStrategy
- Remove positioning strategy used for reporting non-applicable
  for empty delegation calls

 #KT-6971 Fixed
2015-03-26 22:10:19 +03:00
Denis Zharkov
847ea7bc54 Add test case: 'platformStatic' on constructors 2015-03-26 22:10:19 +03:00
Denis Zharkov
637603b584 Prohibit 'native' annotation on constructors
Currently doesn't work for primary ones

 #KT-7000 Fixed
2015-03-26 22:10:19 +03:00
Denis Zharkov
0eecb8bb41 Report illegal modifiers on secondary constructors 2015-03-26 22:10:19 +03:00
Denis Zharkov
c0ac3d3052 Prohibit platformName on secondary constructor
#KT-6999 Fixed
2015-03-26 22:10:19 +03:00
Denis Zharkov
bdff43d2e2 Report error for inappropriate modifiers usages 2015-03-26 22:10:19 +03:00
Denis Zharkov
622dd37e38 Allow secondary constructors without body
#KT-6967 Fixed
2015-03-26 22:10:19 +03:00
Yan Zhulanow
3ff0447c26 Replicate IDEA plugin versions only on TeamCity build 2015-03-26 21:47:57 +03:00
Stanislav Erokhin
0eca750554 Fixed formatter for function expression 2015-03-26 18:23:45 +03:00
Stanislav Erokhin
16dabd49a7 Fix JetTreeVisitor for file case 2015-03-26 18:23:45 +03:00
Stanislav Erokhin
ca19aeae9a Migrate AddInitKeywordFix & ClassObjectToDefaultObjectFix to JetWholeProjectModalAction 2015-03-26 18:23:43 +03:00
Stanislav Erokhin
52f8c5a424 Create DeprecatedLambdaSyntaxFix for whole project 2015-03-26 18:22:53 +03:00
Stanislav Erokhin
3f58806b14 Minor. Divide method moveInsideParenthesesAndReplaceWith 2015-03-26 18:22:53 +03:00
Michael Nedzelsky
f185bb9676 merge serialization.js module into js.serializer 2015-03-26 13:42:30 +03:00
Michael Nedzelsky
f9ef766b2a fix EA-66819 - IOE: VirtualDirectoryImpl.contentsToByteArray
Changes: do not try to read content for virtual file in case it is really a directory
2015-03-26 13:42:30 +03:00
Alexey Tsvetkov
ea1121be85 JS: added test for callable reference as stdlib inline function argument
(cherry picked from commit 03f0c6e)
2015-03-26 13:42:30 +03:00
Alexey Tsvetkov
c630ae985e JS: fix issues with js() usage in inline functions
(cherry picked from commit 1557111)
2015-03-26 13:42:30 +03:00
Alexey Tsvetkov
d440b14953 JS: report error when js() produces empty AST
(cherry picked from commit 5ff5cea)
2015-03-26 13:42:30 +03:00
Alexey Tsvetkov
4c0b1f9a55 JS: generate shorter tag for inline functions
(cherry picked from commit eb4f6b8)
2015-03-26 13:42:29 +03:00
Alexey Tsvetkov
f1980b7d9f JS: removed comma expression decomposition from InlineMetadata
There are used to be two inline tags (corresponding to start, end of inline function).
An expression like "startTag, function, endTag" was parsed into comma expression, then decomposed.
Now, it's just one tag at start, and parser can read function, then stop.
Thus, there is no need to decompose comma expressions.
(cherry picked from commit 8be3628)
2015-03-26 13:42:29 +03:00
Alexey Tsvetkov
396962f3e1 JS: use one tag for inlining
(cherry picked from commit c7e8f52)
2015-03-26 13:42:29 +03:00
Alexey Tsvetkov
43e8e9db86 JS: renamed JsParser->JsAstMapper
(cherry picked from commit e83b253)
2015-03-26 13:42:29 +03:00
Alexey Tsvetkov
d5d6031a24 JS: added tests for recursion cycle in inline functions
(cherry picked from commit b5797eb)
2015-03-26 13:42:29 +03:00
Alexey Tsvetkov
586223ceb4 JS: report error from backend, when inline function is called recursively
(cherry picked from commit 24f2121)
2015-03-26 13:42:28 +03:00
Zalim Bashorov
a271b3209d JS frontend: added diagnostic about secondary constructors not supported yet.
(cherry picked from commit d569ea5)
2015-03-26 13:42:28 +03:00
Michael Nedzelsky
d86153e59f fix navigation is Kotlin/Java with Kotlin/Javascript modules
(cherry picked from commit d01cc8a)
2015-03-26 13:42:28 +03:00
Zalim Bashorov
354f0c2eac Minor: fix testdata
(cherry picked from commit 1b53088)
2015-03-26 13:42:28 +03:00
Zalim Bashorov
09212597a3 JS frontend: added diagnostic about non-toplevel classifiers are unsupported yet.
(cherry picked from commit aaa7f6d)
2015-03-26 13:42:28 +03:00
Zalim Bashorov
37372cae04 Minor in JS frontend: fix compiler warnings.
(cherry picked from commit 1bf7610)
2015-03-26 13:42:27 +03:00
Zalim Bashorov
c439139891 Minor in JS frontend: extract native annotation checkers to separate file.
(cherry picked from commit 68619be)
2015-03-26 13:42:27 +03:00
Zalim Bashorov
1313356cd3 AnnotationChecker -> DeclarationChecker
(cherry picked from commit 8673f95)
2015-03-26 13:42:27 +03:00
Alexey Sedunov
3775791aef Find Usages: Support of secondary constructors and delegation calls
(cherry picked from commit d19e633)
2015-03-25 17:40:21 +03:00
Alexey Sedunov
e78ed540c8 Call Hierarchy: Support secondary constructors
(cherry picked from commit 312a1db)
2015-03-25 17:40:13 +03:00
Alexey Sedunov
5b26cba0b1 References Search: Add extension which looks for constructor usages in delegation calls
(cherry picked from commit fe553ed)
2015-03-25 17:40:09 +03:00
Alexey Sedunov
c3487e23b3 Safe Delete: Support secondary constructors
(cherry picked from commit b45965b)
2015-03-25 17:40:04 +03:00
Alexey Sedunov
ff4253e8c5 Safe Delete: Add test for primary constructor with usages in delegation calls
(cherry picked from commit cefd8b4)
2015-03-25 17:39:59 +03:00
Alexey Sedunov
5bc077df0b Fix retrieval of class constructor
(cherry picked from commit 83e23aa)
2015-03-25 17:39:55 +03:00
Alexey Sedunov
2b8cc12fc5 Change Signature: Support refactoring of primary/secondary constructor by delegation call reference
(cherry picked from commit 5c7debb)
2015-03-25 17:39:51 +03:00
Alexey Sedunov
ab43c1807e Change Signature: Add tests for secondary constructors and delegation calls
(cherry picked from commit 173a28a)
2015-03-25 17:39:46 +03:00
Yan Zhulanow
d358e02505 Remove comment about IDEA version change (not needed in release branches, fix merge) 2015-03-24 17:59:05 +03:00
Yan Zhulanow
c67286466a Replicate idea-version from the main plugin.xml to the android-idea-plugin plugin.xml 2015-03-24 17:07:43 +03:00
Alexander Udalov
e7ddd107d7 Improve built-in initialization error message 2015-03-23 17:16:31 +03:00
Dmitry Jemerov
0d5ca6a543 correct indentation after pressing Enter in KDoc tag
#KT-7044 Fixed
2015-03-23 17:16:29 +03:00
Alexander Udalov
d4a419de2c Don't create KProperty instance for synthetic field
#KT-5759 Fixed
2015-03-23 16:35:41 +03:00
Alexander Udalov
52a45f7eac Fix KClass.simpleName for local classes 2015-03-23 16:35:38 +03:00
Alexander Udalov
667775a3e0 Do not report "no reflection" inspection in JS modules
#KT-7087 Fixed
2015-03-23 16:32:48 +03:00
Alexander Udalov
6422af1846 Do not report "no reflection" inspection where reflection is not used
#KT-7059 Fixed
2015-03-23 16:32:44 +03:00
Evgeny Gerashchenko
6d50e3a068 Enabled "Invert if condition" intention. It was erroneously disabled one year ago. 2015-03-23 15:27:34 +03:00
Evgeny Gerashchenko
2389e8cfdf KT-7021 Don't mark companion object as unused if some stuff from it is used
#KT-7021 fixed
2015-03-23 15:27:31 +03:00
Evgeny Gerashchenko
e6c962b5a6 Finding implicit usages of companion object in containing class. 2015-03-23 15:27:25 +03:00
386 changed files with 6123 additions and 1195 deletions

1
.idea/ant.xml generated
View File

@@ -13,5 +13,6 @@
</buildFile>
<buildFile url="file://$PROJECT_DIR$/pluginPublisher/TeamCityPluginPublisher.xml" />
<buildFile url="file://$PROJECT_DIR$/idea-runner/runner.xml" />
<buildFile url="file://$PROJECT_DIR$/replicate_versions.xml" />
</component>
</project>

View File

@@ -26,7 +26,6 @@
<element id="module-output" name="idea-jps-common" />
<element id="module-output" name="preloader" />
<element id="module-output" name="serialization" />
<element id="module-output" name="serialization.js" />
<element id="module-output" name="serialization.jvm" />
<element id="module-output" name="backend-common" />
<element id="library" level="project" name="builtins" />
@@ -40,6 +39,7 @@
<element id="module-output" name="ide-common" />
<element id="file-copy" path="$PROJECT_DIR$/resources/kotlinManifest.properties" />
<element id="module-output" name="kotlin-android-plugin" />
<element id="module-output" name="js.serializer" />
</element>
<element id="library" level="project" name="javax.inject" />
<element id="directory" name="jps">

1
.idea/modules.xml generated
View File

@@ -49,7 +49,6 @@
<module fileurl="file://$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" filepath="$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/serialization/serialization.iml" filepath="$PROJECT_DIR$/core/serialization/serialization.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/serialization.js/serialization.js.iml" filepath="$PROJECT_DIR$/core/serialization.js/serialization.js.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/serialization.jvm/serialization.jvm.iml" filepath="$PROJECT_DIR$/core/serialization.jvm/serialization.jvm.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/compiler/util/util.iml" filepath="$PROJECT_DIR$/compiler/util/util.iml" />
<module fileurl="file://$PROJECT_DIR$/core/util.runtime/util.runtime.iml" filepath="$PROJECT_DIR$/core/util.runtime/util.runtime.iml" group="core" />

View File

@@ -1,5 +1,6 @@
<project name="Jet CI Steps" default="none">
<import file="build.xml" optional="false"/>
<import file="replicate_versions.xml" optional="false"/>
<property name="build.number" value="snapshot"/>
<property name="jdk16.home" value="${java.home}"/>
@@ -12,6 +13,10 @@
<property name="plugin.xml.bk" value="${version_substitute_dir}/plugin.xml.bk"/>
<property name="plugin.xml.versioned" value="${plugin.xml}.versioned" />
<property name="android-extensions.plugin.xml" value="plugins/android-idea-plugin/src/META-INF/plugin.xml"/>
<property name="android-extensions.plugin.xml.bk" value="${version_substitute_dir}/kotlin-android-extensions.plugin.xml.bk"/>
<property name="android-extensions.plugin.xml.versioned" value="${android-extensions.plugin.xml}.versioned" />
<property name="compiler.version.java" value="compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/KotlinVersion.java"/>
<property name="compiler.version.java.bk" value="${version_substitute_dir}/KotlinVersion.java.bk"/>
<property name="compiler.version.java.versioned" value="${compiler.version.java}.versioned" />
@@ -82,15 +87,24 @@
target.file.versioned="${plugin.xml.versioned}"
test.string="&lt;version&gt;@snapshot@&lt;/version&gt;"/>
<substituteVersionInFile
target.file="${android-extensions.plugin.xml}"
target.file.bk="${android-extensions.plugin.xml.bk}"
target.file.versioned="${android-extensions.plugin.xml.versioned}"
test.string="&lt;version&gt;@snapshot@&lt;/version&gt;"/>
<substituteVersionInFile
target.file="${compiler.version.java}"
target.file.bk="${compiler.version.java.bk}"
target.file.versioned="${compiler.version.java.versioned}"
test.string="public static final String VERSION = &quot;@snapshot@&quot;;"/>
<replicateIdeaVersion target.file="${android-extensions.plugin.xml}" />
</target>
<target name="revertTemplateFiles">
<copy file="${plugin.xml.bk}" tofile="${plugin.xml}" overwrite="true"/>
<copy file="${android-extensions.plugin.xml.bk}" tofile="${android-extensions.plugin.xml}" overwrite="true"/>
<copy file="${compiler.version.java.bk}" tofile="${compiler.version.java}" overwrite="true"/>
<delete dir="${version_substitute_dir}" quiet="true"/>

View File

@@ -99,7 +99,6 @@
<include name="core/descriptors/src"/>
<include name="core/serialization/src"/>
<include name="core/descriptor.loader.java/src"/>
<include name="core/serialization.js/src"/>
<include name="core/serialization.jvm/src"/>
<include name="core/util.runtime/src"/>
<include name="compiler/frontend/src"/>
@@ -127,7 +126,6 @@
<include name="serialization/**"/>
<include name="descriptor.loader.java/**"/>
<include name="frontend.java/**"/>
<include name="serialization.js/**"/>
<include name="serialization.jvm/**"/>
<include name="backend/**"/>
<include name="backend-common/**"/>
@@ -194,7 +192,6 @@
<fileset dir="core/descriptors/src"/>
<fileset dir="core/descriptor.loader.java/src"/>
<fileset dir="core/serialization/src"/>
<fileset dir="core/serialization.js/src"/>
<fileset dir="core/serialization.jvm/src"/>
<fileset dir="core/util.runtime/src"/>
<fileset dir="compiler/frontend/src"/>

View File

@@ -1913,8 +1913,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
JetType returnType = propertyDescriptor.getReturnType();
for (ExpressionCodegenExtension extension : codegenExtensions) {
if (returnType != null && extension.apply(receiver, resolvedCall, context)) {
return StackValue.onStack(typeMapper.mapType(returnType));
if (returnType != null) {
StackValue value = extension.applyProperty(receiver, resolvedCall, context);
if (value != null) return value;
}
}
}
@@ -2352,7 +2353,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (!codegenExtensions.isEmpty()) {
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
for (ExpressionCodegenExtension extension : codegenExtensions) {
if (extension.apply(receiver, resolvedCall, context)) return;
if (extension.applyFunction(receiver, resolvedCall, context)) return;
}
}

View File

@@ -1176,7 +1176,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetSecondaryConstructor constructor =
(JetSecondaryConstructor) DescriptorToSourceUtils.descriptorToDeclaration(constructorDescriptor);
assert constructor != null;
codegen.gen(constructor.getBodyExpression(), Type.VOID_TYPE);
if (constructor.hasBody()) {
codegen.gen(constructor.getBodyExpression(), Type.VOID_TYPE);
}
iv.visitInsn(RETURN);
}

View File

@@ -35,9 +35,17 @@ public trait ExpressionCodegenExtension {
public val v: InstructionAdapter
)
// Function is responsible to put the value on stack by itself.
// Returns false if not applicable, and if stack was not modified.
public fun apply(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): Boolean
/**
* Used for generating custom byte code for the property value obtain. This function has lazy semantics.
* Returns new stack value.
*/
public fun applyProperty(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null
/**
* Used for generating custom byte code for the function call. This function has non-lazy semantics.
* Returns true if the stack was modified.
*/
public fun applyFunction(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): Boolean = false
public fun generateClassSyntheticParts(
classBuilder: ClassBuilder,

View File

@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider
import org.jetbrains.kotlin.resolve.AnnotationChecker
import org.jetbrains.kotlin.resolve.DeclarationChecker
import org.jetbrains.kotlin.resolve.annotations.hasPlatformStaticAnnotation
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.descriptors.ClassKind
@@ -59,12 +59,12 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker
public object KotlinJvmCheckerProvider : AdditionalCheckerProvider(
additionalAnnotationCheckers = listOf(PlatformStaticAnnotationChecker(), LocalFunInlineChecker(), ReifiedTypeParameterAnnotationChecker(), NativeFunChecker()),
additionalDeclarationCheckers = listOf(PlatformStaticAnnotationChecker(), LocalFunInlineChecker(), ReifiedTypeParameterAnnotationChecker(), NativeFunChecker()),
additionalCallCheckers = listOf(NeedSyntheticChecker()),
additionalTypeCheckers = listOf(JavaNullabilityWarningsChecker())
)
public class LocalFunInlineChecker : AnnotationChecker {
public class LocalFunInlineChecker : DeclarationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor.hasInlineAnnotation() &&
@@ -76,7 +76,7 @@ public class LocalFunInlineChecker : AnnotationChecker {
}
}
public class PlatformStaticAnnotationChecker : AnnotationChecker {
public class PlatformStaticAnnotationChecker : DeclarationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor.hasPlatformStaticAnnotation()) {
@@ -116,7 +116,7 @@ public class PlatformStaticAnnotationChecker : AnnotationChecker {
}
}
public class ReifiedTypeParameterAnnotationChecker : AnnotationChecker {
public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor.hasIntrinsicAnnotation()) return

View File

@@ -17,13 +17,15 @@
package org.jetbrains.kotlin.load.kotlin.nativeDeclarations
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.AnnotationChecker
import org.jetbrains.kotlin.resolve.DeclarationChecker
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
import org.jetbrains.kotlin.psi.JetDeclarationWithBody
import org.jetbrains.kotlin.resolve.annotations.hasInlineAnnotation
@@ -38,7 +40,7 @@ public fun DeclarationDescriptor.hasNativeAnnotation(): Boolean {
public class SuppressNoBodyErrorsForNativeDeclarations : SuppressDiagnosticsByAnnotations(FUNCTION_NO_BODY_ERRORS, NATIVE_ANNOTATION_CLASS_NAME)
public class NativeFunChecker : AnnotationChecker {
public class NativeFunChecker : DeclarationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (!descriptor.hasNativeAnnotation()) return
@@ -50,7 +52,10 @@ public class NativeFunChecker : AnnotationChecker {
diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration))
}
if (declaration is JetDeclarationWithBody && declaration.hasBody()) {
if (descriptor is ConstructorDescriptor) {
diagnosticHolder.report(Errors.INAPPLICABLE_ANNOTATION.on(declaration));
}
else if (declaration is JetDeclarationWithBody && declaration.hasBody()) {
diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY.on(declaration))
}

View File

@@ -1441,10 +1441,7 @@ public class JetControlFlowProcessor {
processParameters(constructor.getValueParameters());
generateCallOrMarkUnresolved(constructor.getDelegationCall());
if (constructor.getDelegationCall() != null &&
constructor.getDelegationCall().getCalleeExpression() != null &&
!constructor.getDelegationCall().getCalleeExpression().isThis()
) {
if (!constructor.getDelegationCall().isCallToThis()) {
generateClassOrObjectInitializers(classOrObject);
}

View File

@@ -155,8 +155,7 @@ public interface Errors {
// Secondary constructors
DiagnosticFactory0<JetConstructorDelegationCall> CYCLIC_CONSTRUCTOR_DELEGATION_CALL =
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
DiagnosticFactory0<JetConstructorDelegationReferenceExpression> CYCLIC_CONSTRUCTOR_DELEGATION_CALL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetSecondaryConstructor> SECONDARY_CONSTRUCTOR_IN_OBJECT = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetDelegatorToSuperCall> SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
@@ -165,10 +164,12 @@ public interface Errors {
DiagnosticFactory0<JetConstructorDelegationCall> PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED =
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
DiagnosticFactory0<JetConstructorDelegationCall> DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR =
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
DiagnosticFactory0<JetConstructorDelegationReferenceExpression> DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR =
DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetConstructorDelegationCall> EXPLICIT_DELEGATION_CALL_REQUIRED =
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
// Trait-specific
@@ -411,8 +412,7 @@ public interface Errors {
DiagnosticFactory0<JetExpression> NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> OVERLOAD_RESOLUTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> NONE_APPLICABLE =
DiagnosticFactory1.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL_OR_DEFAULT);
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> CANNOT_COMPLETE_RESOLVE = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> UNRESOLVED_REFERENCE_WRONG_RECEIVER = DiagnosticFactory1.create(ERROR);

View File

@@ -62,6 +62,9 @@ public object PositioningStrategies {
element.getNameIdentifier() ?: element.getObjectKeyword()
)
}
is JetConstructorDelegationCall -> {
return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(element)
}
else -> {
return super.mark(element)
}
@@ -415,24 +418,12 @@ public object PositioningStrategies {
public val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: PositioningStrategy<JetConstructorDelegationCall> =
object : PositioningStrategy<JetConstructorDelegationCall>() {
override fun mark(element: JetConstructorDelegationCall): List<TextRange> {
if (element.getCalleeExpression()?.isEmpty() ?: false) {
if (element.isImplicit()) {
val constructor = element.getStrictParentOfType<JetSecondaryConstructor>()!!
return markElement(constructor.getConstructorKeyword())
val valueParameterList = constructor.getValueParameterList() ?: return markElement(constructor)
return markRange(constructor.getConstructorKeyword(), valueParameterList.getLastChild())
}
return markElement(element.getCalleeExpression() ?: element)
}
}
public val SECONDARY_CONSTRUCTOR_DELEGATION_CALL_OR_DEFAULT: PositioningStrategy<PsiElement> =
object : PositioningStrategy<PsiElement>() {
override fun mark(element: PsiElement): List<TextRange> {
val parent = element.getParent()
if (parent is JetConstructorDelegationCall) {
return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(parent)
}
else {
return DEFAULT.mark(element)
}
}
}
}

View File

@@ -425,6 +425,8 @@ public class DefaultErrorMessages {
MAP.put(PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED, "Primary constructor call expected");
MAP.put(DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR, "Call to super is not allowed in enum constructor");
MAP.put(PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS, "Primary constructor required for data class");
MAP.put(EXPLICIT_DELEGATION_CALL_REQUIRED,
"Explicit 'this' or 'super' call is required. There is no constructor in superclass that can be called without arguments");
MAP.put(INIT_KEYWORD_BEFORE_CLASS_INITIALIZER_EXPECTED, "Expecting 'init' keyword before class initializer");

View File

@@ -23,3 +23,5 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererImpl
public fun <P> renderParameter(parameter: P, renderer: Renderer<P>?): Any = renderer?.render(parameter) ?: parameter
public fun ClassDescriptor.renderKindWithName(): String = "${DescriptorRendererImpl.getClassKindPrefix(this)} '${getName()}'"
public fun ClassDescriptor.renderKind(): String = DescriptorRendererImpl.getClassKindPrefix(this)

View File

@@ -423,9 +423,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
private void parsePostfixExpression() {
PsiBuilder.Marker expression = mark();
boolean firstExpressionParsed;
boolean doubleColonExpression = parseDoubleColonExpression();
if (!doubleColonExpression) {
parseAtomicExpression();
firstExpressionParsed = parseAtomicExpression();
}
else {
firstExpressionParsed = true;
}
while (true) {
@@ -439,19 +443,24 @@ public class JetExpressionParsing extends AbstractJetParsing {
else if (!doubleColonExpression && parseCallSuffix()) {
expression.done(CALL_EXPRESSION);
}
else if (at(DOT)) {
advance(); // DOT
else if (at(DOT) || at(SAFE_ACCESS)) {
IElementType expressionType = at(DOT) ? DOT_QUALIFIED_EXPRESSION : SAFE_ACCESS_EXPRESSION;
advance(); // DOT or SAFE_ACCESS
if (!firstExpressionParsed) {
expression.drop();
expression = mark();
}
parseCallExpression();
expression.done(DOT_QUALIFIED_EXPRESSION);
}
else if (at(SAFE_ACCESS)) {
advance(); // SAFE_ACCESS
parseCallExpression();
expression.done(SAFE_ACCESS_EXPRESSION);
if (firstExpressionParsed) {
expression.done(expressionType);
}
else {
firstExpressionParsed = true;
continue;
}
}
else if (atSet(Precedence.POSTFIX.getOperations())) {
parseOperationReference();
@@ -557,9 +566,11 @@ public class JetExpressionParsing extends AbstractJetParsing {
* : "package" // for the root package
* ;
*/
private void parseAtomicExpression() {
private boolean parseAtomicExpression() {
// System.out.println("atom at " + myBuilder.getTokenText());
boolean ok = true;
if (at(LPAR)) {
parseParenthesizedExpression();
}
@@ -625,9 +636,12 @@ public class JetExpressionParsing extends AbstractJetParsing {
parseStringTemplate();
}
else if (!parseLiteralConstant()) {
ok = false;
// TODO: better recovery if FIRST(element) did not match
errorWithRecovery("Expecting an element", EXPRESSION_FOLLOW);
}
return ok;
}
/*

View File

@@ -873,7 +873,7 @@ public class JetParsing extends AbstractJetParsing {
advance(); // CONSTRUCTOR_KEYWORD
TokenSet valueArgsRecoverySet = TokenSet.create(COLON, LBRACE, SEMICOLON, RPAR);
TokenSet valueArgsRecoverySet = TokenSet.create(COLON, LBRACE, SEMICOLON, RPAR, EOL_OR_SEMICOLON, RBRACE);
if (at(LPAR)) {
parseValueParameterList(false, /*typeRequired = */ true, valueArgsRecoverySet);
}
@@ -888,16 +888,26 @@ public class JetParsing extends AbstractJetParsing {
if (at(THIS_KEYWORD) || at(SUPER_KEYWORD)) {
parseThisOrSuper();
myExpressionParsing.parseValueArgumentList();
}
else {
// if we're on LPAR it's probably start of value arguments list
if (!at(LPAR)) {
advance(); // wrong delegation call keyword?
}
error("Expecting a 'this' or 'super' constructor call");
}
PsiBuilder.Marker beforeWrongDelegationCallee = null;
if (!at(LPAR)) {
beforeWrongDelegationCallee = mark();
advance(); // wrong delegation callee
}
myExpressionParsing.parseValueArgumentList();
myExpressionParsing.parseValueArgumentList();
if (beforeWrongDelegationCallee != null) {
if (at(LBRACE)) {
beforeWrongDelegationCallee.drop();
}
else {
beforeWrongDelegationCallee.rollbackTo();
}
}
}
delegationCall.done(CONSTRUCTOR_DELEGATION_CALL);
}
@@ -908,7 +918,9 @@ public class JetParsing extends AbstractJetParsing {
emptyDelegationCall.done(CONSTRUCTOR_DELEGATION_CALL);
}
parseBlock();
if (at(LBRACE)) {
parseBlock();
}
}
private void parseThisOrSuper() {

View File

@@ -64,4 +64,14 @@ public class JetConstructorDelegationCall extends JetElementImpl implements JetC
public JetConstructorDelegationReferenceExpression getCalleeExpression() {
return findChildByClass(JetConstructorDelegationReferenceExpression.class);
}
public boolean isImplicit() {
JetConstructorDelegationReferenceExpression callee = getCalleeExpression();
return callee != null && callee.getFirstChild() == null;
}
public boolean isCallToThis() {
JetConstructorDelegationReferenceExpression callee = getCalleeExpression();
return callee != null && callee.isThis();
}
}

View File

@@ -28,8 +28,4 @@ public class JetConstructorDelegationReferenceExpression extends JetExpressionIm
public boolean isThis() {
return findChildByType(JetTokens.THIS_KEYWORD) != null;
}
public boolean isEmpty() {
return getFirstChild() == null;
}
}

View File

@@ -363,7 +363,7 @@ public class JetPsiFactory(private val project: Project) {
public fun createConstructorDelegationCall(text: String): JetConstructorDelegationCall {
val colonOrEmpty = if (text.isEmpty()) "" else ": "
return createClass("class A { constructor()$colonOrEmpty$text {}").getSecondaryConstructors().first().getDelegationCall()!!
return createClass("class A { constructor()$colonOrEmpty$text {}").getSecondaryConstructors().first().getDelegationCall()
}
public inner class IfChainBuilder() {

View File

@@ -88,7 +88,7 @@ public class JetSecondaryConstructor extends JetDeclarationStub<KotlinPlaceHolde
@Nullable
@Override
public JetExpression getBodyExpression() {
public JetBlockExpression getBodyExpression() {
return findChildByClass(JetBlockExpression.class);
}
@@ -105,7 +105,7 @@ public class JetSecondaryConstructor extends JetDeclarationStub<KotlinPlaceHolde
@Override
public boolean hasBody() {
return true;
return getBodyExpression() != null;
}
@Override
@@ -172,16 +172,36 @@ public class JetSecondaryConstructor extends JetDeclarationStub<KotlinPlaceHolde
throw new IncorrectOperationException("setName to constructor");
}
@Nullable
@NotNull
public JetConstructorDelegationCall getDelegationCall() {
return findChildByClass(JetConstructorDelegationCall.class);
}
public boolean hasImplicitDelegationCall() {
return getDelegationCall().isImplicit();
}
@NotNull
public JetClassOrObject getClassOrObject() {
return (JetClassOrObject) getParent().getParent();
}
@NotNull
public JetConstructorDelegationCall replaceImplicitDelegationCallWithExplicit(boolean isThis) {
JetPsiFactory psiFactory = new JetPsiFactory(getProject());
JetConstructorDelegationCall current = getDelegationCall();
assert current.isImplicit()
: "Method should not be called with explicit delegation call: " + getText();
current.delete();
PsiElement colon = addAfter(psiFactory.createColon(), getValueParameterList());
String delegationName = isThis ? "this" : "super";
return (JetConstructorDelegationCall) addAfter(psiFactory.createConstructorDelegationCall(delegationName + "()"), colon);
}
@NotNull
public PsiElement getConstructorKeyword() {
return findNotNullChildByType(JetTokens.CONSTRUCTOR_KEYWORD);

View File

@@ -24,4 +24,11 @@ public class JetTreeVisitor<D> extends JetVisitor<Void, D> {
element.acceptChildren(this, data);
return null;
}
@Override
public Void visitJetFile(@NotNull JetFile file, D data) {
super.visitJetFile(file, data);
file.acceptChildren(this, data);
return null;
}
}

View File

@@ -45,4 +45,8 @@ public class JetValueArgumentList extends JetElementImpl {
return findChildByType(JetTokens.RPAR);
}
@Nullable
public PsiElement getLeftParenthesis() {
return findChildByType(JetTokens.LPAR);
}
}

View File

@@ -18,17 +18,17 @@ package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.resolve.calls.checkers.*
private val DEFAULT_ANNOTATION_CHECKERS = listOf(DataClassAnnotationChecker())
private val DEFAULT_DECLARATION_CHECKERS = listOf(DataClassAnnotationChecker())
private val DEFAULT_CALL_CHECKERS = listOf(CapturingInClosureChecker(), InlineCheckerWrapper(), ReifiedTypeParameterSubstitutionChecker())
private val DEFAULT_TYPE_CHECKERS = listOf(TypeApproximator())
public abstract class AdditionalCheckerProvider(
additionalAnnotationCheckers: List<AnnotationChecker>,
additionalDeclarationCheckers: List<DeclarationChecker>,
additionalCallCheckers: List<CallChecker>,
additionalTypeCheckers: List<AdditionalTypeChecker>
) {
public val annotationCheckers: List<AnnotationChecker> = DEFAULT_ANNOTATION_CHECKERS + additionalAnnotationCheckers
public val declarationCheckers: List<DeclarationChecker> = DEFAULT_DECLARATION_CHECKERS + additionalDeclarationCheckers
public val callCheckers: List<CallChecker> = DEFAULT_CALL_CHECKERS + additionalCallCheckers
public val additionalTypeCheckers: List<AdditionalTypeChecker> = DEFAULT_TYPE_CHECKERS + additionalTypeCheckers

View File

@@ -217,8 +217,9 @@ public class BodyResolver {
PsiElement constructorToReport = DescriptorToSourceUtils.descriptorToDeclaration(currentConstructor);
if (constructorToReport != null) {
JetConstructorDelegationCall call = ((JetSecondaryConstructor) constructorToReport).getDelegationCall();
assert call != null : "resolved call can't be null";
trace.report(CYCLIC_CONSTRUCTOR_DELEGATION_CALL.on(call));
assert call.getCalleeExpression() != null
: "Callee expression of delegation call should not be null on cycle as there should be explicit 'this' calls";
trace.report(CYCLIC_CONSTRUCTOR_DELEGATION_CALL.on(call.getCalleeExpression()));
}
currentConstructor = getDelegatedConstructor(currentConstructor);
@@ -229,7 +230,7 @@ public class BodyResolver {
@Nullable
private ConstructorDescriptor getDelegatedConstructor(@NotNull ConstructorDescriptor constructor) {
ResolvedCall<ConstructorDescriptor> call = trace.get(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor);
return call == null ? null : call.getResultingDescriptor().getOriginal();
return call == null || !call.getStatus().isSuccess() ? null : call.getResultingDescriptor().getOriginal();
}
public void resolveBodies(@NotNull BodiesResolveContext c) {

View File

@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.builtins.*
public class DataClassAnnotationChecker : AnnotationChecker {
public class DataClassAnnotationChecker : DeclarationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor !is ClassDescriptor) return
if (declaration !is JetClassOrObject) return

View File

@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
public trait AnnotationChecker {
public trait DeclarationChecker {
public fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink);

View File

@@ -105,6 +105,14 @@ public class DeclarationsChecker {
modifiersChecker.checkModifiersForDeclaration(property, propertyDescriptor);
}
for (Map.Entry<JetSecondaryConstructor, ConstructorDescriptor> entry : bodiesResolveContext.getSecondaryConstructors().entrySet()) {
ConstructorDescriptor constructorDescriptor = entry.getValue();
JetSecondaryConstructor declaration = entry.getKey();
modifiersChecker.reportIllegalModalityModifiers(declaration);
reportErrorIfHasIllegalModifier(declaration);
modifiersChecker.checkModifiersForDeclaration(declaration, constructorDescriptor);
}
}
private void reportErrorIfHasIllegalModifier(JetModifierListOwner declaration) {

View File

@@ -145,17 +145,24 @@ public class ModifiersChecker {
checkDefaultModifier(modifierListOwner);
checkModalityModifiers(modifierListOwner);
checkVisibilityModifiers(modifierListOwner, descriptor);
checkVarianceModifiersOfTypeParameters(modifierListOwner);
checkVarianceModifiers(modifierListOwner);
checkVarargsModifiers(modifierListOwner, descriptor);
}
checkPlatformNameApplicability(descriptor);
runAnnotationCheckers(modifierListOwner, descriptor);
runDeclarationCheckers(modifierListOwner, descriptor);
}
private void checkVarargsModifiers(@NotNull JetDeclaration owner, @NotNull MemberDescriptor descriptor) {
if (!(owner instanceof JetParameter)) {
reportIllegalModifiers(owner, Collections.singleton(VARARG_KEYWORD));
}
}
public void checkModifiersForLocalDeclaration(@NotNull JetDeclaration modifierListOwner, @NotNull DeclarationDescriptor descriptor) {
reportIllegalModalityModifiers(modifierListOwner);
reportIllegalVisibilityModifiers(modifierListOwner);
checkPlatformNameApplicability(descriptor);
runAnnotationCheckers(modifierListOwner, descriptor);
runDeclarationCheckers(modifierListOwner, descriptor);
}
public void reportIllegalModalityModifiers(@NotNull JetModifierListOwner modifierListOwner) {
@@ -288,7 +295,8 @@ public class ModifiersChecker {
JetAnnotationEntry annotationEntry = trace.get(BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotation);
if (annotationEntry == null) return;
if (!DescriptorUtils.isTopLevelDeclaration(descriptor) || !(descriptor instanceof FunctionDescriptor)) {
if (!DescriptorUtils.isTopLevelDeclaration(descriptor) || !(descriptor instanceof FunctionDescriptor) ||
descriptor instanceof ConstructorDescriptor) {
trace.report(INAPPLICABLE_ANNOTATION.on(annotationEntry));
}
@@ -394,13 +402,14 @@ public class ModifiersChecker {
return Visibilities.INTERNAL;
}
private void runAnnotationCheckers(@NotNull JetDeclaration declaration, @NotNull DeclarationDescriptor descriptor) {
for (AnnotationChecker checker : additionalCheckerProvider.getAnnotationCheckers()) {
private void runDeclarationCheckers(@NotNull JetDeclaration declaration, @NotNull DeclarationDescriptor descriptor) {
for (DeclarationChecker checker : additionalCheckerProvider.getDeclarationCheckers()) {
checker.check(declaration, descriptor, trace);
}
}
public void checkVarianceModifiersOfTypeParameters(@NotNull JetModifierListOwner modifierListOwner) {
public void checkVarianceModifiers(@NotNull JetModifierListOwner modifierListOwner) {
reportIllegalModifiers(modifierListOwner, Arrays.asList(IN_KEYWORD, OUT_KEYWORD, REIFIED_KEYWORD));
if (!(modifierListOwner instanceof JetTypeParameterListOwner)) return;
List<JetTypeParameter> typeParameters = ((JetTypeParameterListOwner) modifierListOwner).getTypeParameters();
for (JetTypeParameter typeParameter : typeParameters) {

View File

@@ -188,7 +188,17 @@ public class CallResolver {
@NotNull Collection<ResolutionCandidate<D>> candidates,
@NotNull CallTransformer<D, F> callTransformer
) {
TracingStrategy tracing = TracingStrategyImpl.create(referenceExpression, context.call);
return computeTasksFromCandidatesAndResolvedCall(context, candidates, callTransformer,
TracingStrategyImpl.create(referenceExpression, context.call));
}
@NotNull
private <D extends CallableDescriptor, F extends D> OverloadResolutionResults<F> computeTasksFromCandidatesAndResolvedCall(
@NotNull BasicCallResolutionContext context,
@NotNull Collection<ResolutionCandidate<D>> candidates,
@NotNull CallTransformer<D, F> callTransformer,
@NotNull TracingStrategy tracing
) {
List<ResolutionTask<D, F>> prioritizedTasks =
taskPrioritizer.<D, F>computePrioritizedTasksFromCandidates(context, candidates, tracing);
return doResolveCallOrGetCachedResults(context, prioritizedTasks, callTransformer, tracing);
@@ -291,11 +301,10 @@ public class CallResolver {
public OverloadResolutionResults<FunctionDescriptor> resolveConstructorDelegationCall(
@NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull DataFlowInfo dataFlowInfo,
@NotNull ConstructorDescriptor constructorDescriptor,
@Nullable JetConstructorDelegationCall call
@NotNull JetConstructorDelegationCall call
) {
// Returns `null` when there is nothing to resolve in trivial cases like `null` call expression or
// Method returns `null` when there is nothing to resolve in trivial cases like `null` call expression or
// when super call should be conventional enum constructor and super call should be empty
if (call == null) return null;
BasicCallResolutionContext context = BasicCallResolutionContext.create(
trace, scope,
@@ -306,13 +315,13 @@ public class CallResolver {
if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context);
if (constructorDescriptor.getContainingDeclaration().getKind() == ClassKind.ENUM_CLASS &&
call.getCalleeExpression().isEmpty()) {
if (constructorDescriptor.getContainingDeclaration().getKind() == ClassKind.ENUM_CLASS && call.isImplicit()) {
return null;
}
return resolveConstructorDelegationCall(
context,
call,
call.getCalleeExpression(),
constructorDescriptor
);
@@ -321,6 +330,7 @@ public class CallResolver {
@NotNull
private OverloadResolutionResults<FunctionDescriptor> resolveConstructorDelegationCall(
@NotNull BasicCallResolutionContext context,
@NotNull JetConstructorDelegationCall call,
@NotNull JetConstructorDelegationReferenceExpression calleeExpression,
@NotNull ConstructorDescriptor calleeConstructor
) {
@@ -328,7 +338,7 @@ public class CallResolver {
boolean isThisCall = calleeExpression.isThis();
if (currentClassDescriptor.getKind() == ClassKind.ENUM_CLASS && !isThisCall) {
context.trace.report(DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR.on((JetConstructorDelegationCall) calleeExpression.getParent()));
context.trace.report(DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR.on(calleeExpression));
return checkArgumentTypesAndFail(context);
}
@@ -364,7 +374,11 @@ public class CallResolver {
knownTypeParametersSubstitutor));
}
return computeTasksFromCandidatesAndResolvedCall(context, calleeExpression, candidates, CallTransformer.FUNCTION_CALL_TRANSFORMER);
TracingStrategy tracing = call.isImplicit() ?
new TracingStrategyForImplicitConstructorDelegationCall(call, context.call) :
TracingStrategyImpl.create(calleeExpression, context.call);
return computeTasksFromCandidatesAndResolvedCall(context, candidates, CallTransformer.FUNCTION_CALL_TRANSFORMER, tracing);
}
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithKnownCandidate(

View File

@@ -0,0 +1,145 @@
/*
* Copyright 2010-2015 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.resolve.calls.tasks
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.diagnostics.Errors.UNRESOLVED_REFERENCE
import org.jetbrains.kotlin.diagnostics.Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER
import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.psi.JetConstructorDelegationCall
import org.jetbrains.kotlin.psi.JetFunctionLiteralArgument
import org.jetbrains.kotlin.psi.JetSecondaryConstructor
import org.jetbrains.kotlin.resolve.BindingContext.CALL
import org.jetbrains.kotlin.resolve.BindingContext.REFERENCE_TARGET
import org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.JetType
public class TracingStrategyForImplicitConstructorDelegationCall(
val delegationCall: JetConstructorDelegationCall, call: Call
) : AbstractTracingStrategy(delegationCall.getCalleeExpression()!!, call) {
val calleeExpression = delegationCall.getCalleeExpression()
override fun bindCall(trace: BindingTrace, call: Call) {
trace.record(CALL, call.getCalleeExpression(), call)
}
override fun <D : CallableDescriptor> bindReference(trace: BindingTrace, resolvedCall: ResolvedCall<D>) {
val descriptor = resolvedCall.getCandidateDescriptor()
val storedReference = trace.get(REFERENCE_TARGET, calleeExpression)
if (storedReference == null || !ErrorUtils.isError(descriptor)) {
trace.record(REFERENCE_TARGET, calleeExpression, descriptor)
}
}
override fun <D : CallableDescriptor> bindResolvedCall(trace: BindingTrace, resolvedCall: ResolvedCall<D>) {
trace.record(RESOLVED_CALL, call, resolvedCall)
}
override fun unresolvedReference(trace: BindingTrace) {
trace.report(UNRESOLVED_REFERENCE.on(calleeExpression, calleeExpression))
}
override fun <D : CallableDescriptor> unresolvedReferenceWrongReceiver(trace: BindingTrace, candidates: Collection<ResolvedCall<D>>) {
trace.report(UNRESOLVED_REFERENCE_WRONG_RECEIVER.on(reference, candidates))
}
override fun noValueForParameter(trace: BindingTrace, valueParameter: ValueParameterDescriptor) {
reportError(trace)
}
override fun <D : CallableDescriptor?> ambiguity(trace: BindingTrace, descriptors: MutableCollection<out ResolvedCall<D>>) {
reportError(trace)
}
override fun <D : CallableDescriptor?> noneApplicable(trace: BindingTrace, descriptors: MutableCollection<out ResolvedCall<D>>) {
reportError(trace)
}
override fun invisibleMember(trace: BindingTrace, descriptor: DeclarationDescriptorWithVisibility) {
reportError(trace)
}
private fun reportError(trace: BindingTrace) {
trace.report(Errors.EXPLICIT_DELEGATION_CALL_REQUIRED.on(delegationCall))
}
// Underlying methods should not be called because such errors are impossible
// when resolving delegation call
override fun <D : CallableDescriptor?> cannotCompleteResolve(trace: BindingTrace, descriptors: MutableCollection<out ResolvedCall<D>>) {
unexpectedError("cannotCompleteResolve")
}
override fun instantiationOfAbstractClass(trace: BindingTrace) {
unexpectedError("instantiationOfAbstractClass")
}
override fun abstractSuperCall(trace: BindingTrace) {
unexpectedError("abstractSuperCall")
}
override fun nestedClassAccessViaInstanceReference(
trace: BindingTrace, classDescriptor: ClassDescriptor, explicitReceiverKind: ExplicitReceiverKind
) {
unexpectedError("nestedClassAccessViaInstanceReference")
}
override fun unsafeCall(trace: BindingTrace, type: JetType, isCallForImplicitInvoke: Boolean) {
unexpectedError("unsafeCall")
}
override fun unnecessarySafeCall(trace: BindingTrace, type: JetType) {
unexpectedError("unnecessarySafeCall")
}
override fun danglingFunctionLiteralArgumentSuspected(
trace: BindingTrace, functionLiteralArguments: MutableList<JetFunctionLiteralArgument>
) {
unexpectedError("danglingFunctionLiteralArgumentSuspected")
}
override fun missingReceiver(trace: BindingTrace, expectedReceiver: ReceiverParameterDescriptor) {
unexpectedError("missingReceiver")
}
override fun wrongReceiverType(trace: BindingTrace, receiverParameter: ReceiverParameterDescriptor, receiverArgument: ReceiverValue) {
unexpectedError("wrongReceiverType")
}
override fun noReceiverAllowed(trace: BindingTrace) {
unexpectedError("noReceiverAllowed")
}
override fun wrongNumberOfTypeArguments(trace: BindingTrace, expectedTypeArgumentCount: Int) {
unexpectedError("wrongNumberOfTypeArguments")
}
override fun typeInferenceFailed(trace: BindingTrace, data: InferenceErrorData) {
unexpectedError("typeInferenceFailed")
}
private fun unexpectedError(type: String) {
throw AssertionError("Unexpected error type: $type")
}
}

View File

@@ -22,6 +22,8 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.isSubpackageOf
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.TypeUtils.makeStarProjection
@@ -125,4 +127,12 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
arguments.add(TypeProjectionImpl(returnType))
return JetTypeImpl(annotations, classDescriptor.getTypeConstructor(), false, arguments, classDescriptor.getMemberScope(arguments))
}
companion object {
public fun isReflectionType(type: JetType): Boolean {
val descriptor = type.getConstructor().getDeclarationDescriptor() ?: return false
val fqName = DescriptorUtils.getFqName(descriptor)
return fqName.isSafe() && fqName.toSafe().isSubpackageOf(KOTLIN_REFLECT_FQ_NAME)
}
}
}

View File

@@ -9,10 +9,3 @@ class Foo {
return [fancy] 1
}
}
fun test() {
class A {
fun foo(){}
}
}

View File

@@ -1,4 +1,3 @@
WARNING: compiler/testData/cli/js/diagnosticForUnhandledElements.kt: (8, 21) Parameter 'foo' is never used
ERROR: compiler/testData/cli/js/diagnosticForUnhandledElements.kt: (9, 16) Cannot translate (not supported yet): '[fancy] 1'
ERROR: compiler/testData/cli/js/diagnosticForUnhandledElements.kt: (15, 5) Cannot translate (not supported yet): 'class A {...'
COMPILATION_ERROR
COMPILATION_ERROR

View File

@@ -0,0 +1 @@
package android.appwidget

View File

@@ -0,0 +1 @@
package android.inputmethodservice

View File

@@ -0,0 +1 @@
package android.opengl

View File

@@ -0,0 +1 @@
package android.webkit

View File

@@ -9,4 +9,8 @@ plugin\:org.jetbrains.kotlin.android\:androidRes=$TESTDATA_DIR$/androidPlugin/re
$TESTDATA_DIR$/pluginSimple.kt
$TESTDATA_DIR$/androidPlugin/androidApp.kt
$TESTDATA_DIR$/androidPlugin/androidView.kt
$TESTDATA_DIR$/androidPlugin/androidWidget.kt
$TESTDATA_DIR$/androidPlugin/androidWidget.kt
$TESTDATA_DIR$/androidPlugin/fakeAppwidgetPackage.kt
$TESTDATA_DIR$/androidPlugin/fakeInputMethodServicePackage.kt
$TESTDATA_DIR$/androidPlugin/fakeOpenglPackage.kt
$TESTDATA_DIR$/androidPlugin/fakeWebkitPackage.kt

View File

@@ -7,4 +7,8 @@ plugin\:org.jetbrains.kotlin.android\:androidManifest=$TESTDATA_DIR$/androidPlug
$TESTDATA_DIR$/pluginSimple.kt
$TESTDATA_DIR$/androidPlugin/androidApp.kt
$TESTDATA_DIR$/androidPlugin/androidView.kt
$TESTDATA_DIR$/androidPlugin/androidWidget.kt
$TESTDATA_DIR$/androidPlugin/androidWidget.kt
$TESTDATA_DIR$/androidPlugin/fakeAppwidgetPackage.kt
$TESTDATA_DIR$/androidPlugin/fakeInputMethodServicePackage.kt
$TESTDATA_DIR$/androidPlugin/fakeOpenglPackage.kt
$TESTDATA_DIR$/androidPlugin/fakeWebkitPackage.kt

View File

@@ -11,7 +11,7 @@ class A(val result: Int) {
object C {
}
constructor() : this(foo() + prop + B.bar() + B.prop + C) {}
constructor() : this(foo() + prop + B.bar() + B.prop + C)
}
fun box(): String {

View File

@@ -1,13 +1,13 @@
open class A(val x: String = "abc", val y: String = "efg") {
constructor(x: String, y: String, z: Int): this(x, y + "#" + z.toString()) {}
constructor(x: String, y: String, z: Int): this(x, y + "#" + z.toString())
override fun toString() = "$x#$y"
}
class B : A {
constructor(x: String, y: String, z: Int): super(x, y + z.toString()) {}
constructor(x: String = "xyz", y: String = "123") : super(x, y) {}
constructor(x: Double): super(x.toString()) {}
constructor(x: String, y: String, z: Int): super(x, y + z.toString())
constructor(x: String = "xyz", y: String = "123") : super(x, y)
constructor(x: Double): super(x.toString())
}
fun box(): String {

View File

@@ -9,7 +9,7 @@ class B : A {
val global = B()
class C(x: Int) : A by global {
constructor(): this(1) {}
constructor(): this(1)
}
fun box(): String {

View File

@@ -1,11 +1,11 @@
open class B<T>(val x: T, val y: T) {
constructor(x: T): this(x, x) {}
constructor(x: T): this(x, x)
override fun toString() = "$x#$y"
}
class A : B<String> {
constructor(): super("default") {}
constructor(x: String): super(x, "default") {}
constructor(): super("default")
constructor(x: String): super(x, "default")
}
fun box(): String {

View File

@@ -0,0 +1,39 @@
import kotlin.reflect.KClass
import kotlin.test.assertEquals
fun check(klass: KClass<*>, expectedName: String) {
assertEquals(expectedName, klass.simpleName)
}
fun localInMethod() {
fun localInMethod(unused: Any?) {
class Local
check(Local::class, "Local")
class `Local$With$Dollars`
check(`Local$With$Dollars`::class, "Local\$With\$Dollars")
}
localInMethod(null)
class Local
check(Local::class, "Local")
class `Local$With$Dollars`
check(`Local$With$Dollars`::class, "Local\$With\$Dollars")
}
class LocalInConstructor {
init {
class Local
check(Local::class, "Local")
class `Local$With$Dollars`
check(`Local$With$Dollars`::class, "Local\$With\$Dollars")
}
}
fun box(): String {
localInMethod()
LocalInConstructor()
return "OK"
}

View File

@@ -0,0 +1,14 @@
import kotlin.reflect.jvm.kotlin
class A {
// There's a synthetic "$kotlinClass" field here
}
fun box(): String {
for (field in javaClass<A>().getDeclaredFields()) {
val prop = field.kotlin
if (prop != null) return "Fail, property found: $prop"
}
return "OK"
}

View File

@@ -30,7 +30,13 @@ annotation class annotated(val text: String = "not given")
class LegalModifier(val a: Int, annotated private var b: String, annotated vararg <!UNUSED_PARAMETER!>v<!>: Int)
//Check illegal modifier in constructor parameters
class IllegalModifiers1(<!ILLEGAL_MODIFIER!>private<!> <!UNUSED_PARAMETER!>a<!>: Int)
class IllegalModifiers1(
<!ILLEGAL_MODIFIER!>in<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>reified<!>
<!ILLEGAL_MODIFIER!>enum<!>
<!ILLEGAL_MODIFIER!>private<!>
<!UNUSED_PARAMETER!>a<!>: Int)
//Check multiple illegal modifiers in constructor
class IllegalModifiers2(<!ILLEGAL_MODIFIER!>private<!> <!ILLEGAL_MODIFIER!>abstract<!> <!UNUSED_PARAMETER!>a<!>: Int)
@@ -57,10 +63,10 @@ abstract class IllegalModifiers5() {
private fun qux() {
//Check illegal modifier in catch block
try {} catch (<!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
try {} catch (<!ILLEGAL_MODIFIER!>in<!> <!ILLEGAL_MODIFIER!>out<!> <!ILLEGAL_MODIFIER!>reified<!> <!ILLEGAL_MODIFIER!>enum<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
//Check multiple illegal modifiers in catch block
try {} catch (<!ILLEGAL_MODIFIER!>abstract<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
try {} catch (<!ILLEGAL_MODIFIER!>in<!> <!ILLEGAL_MODIFIER!>out<!> <!ILLEGAL_MODIFIER!>reified<!> <!ILLEGAL_MODIFIER!>enum<!> <!ILLEGAL_MODIFIER!>abstract<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
//Check annotations with illegal modifiers
try {} catch (annotated("a text") <!ILLEGAL_MODIFIER!>abstract<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
@@ -80,4 +86,52 @@ abstract class IllegalModifiers6() {
<!ILLEGAL_MODIFIER!>public<!> annotated init {}
<!ILLEGAL_MODIFIER!>private<!> <!NOT_AN_ANNOTATION_CLASS!>IllegalModifiers6()<!> init {}
}
}
// strange inappropriate modifiers usages
<!ILLEGAL_MODIFIER!>override<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>in<!>
<!ILLEGAL_MODIFIER!>vararg<!>
<!ILLEGAL_MODIFIER!>reified<!>
class IllegalModifiers7() {
<!ILLEGAL_ENUM_ANNOTATION!>enum<!>
<!ILLEGAL_MODIFIER!>inner<!>
<!ILLEGAL_ANNOTATION_KEYWORD!>annotation<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>in<!>
<!ILLEGAL_MODIFIER!>vararg<!>
<!ILLEGAL_MODIFIER!>reified<!>
val x = 1
<!ILLEGAL_ENUM_ANNOTATION!>enum<!>
<!ILLEGAL_MODIFIER!>inner<!>
<!ILLEGAL_ANNOTATION_KEYWORD!>annotation<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>in<!>
<!ILLEGAL_MODIFIER!>vararg<!>
<!ILLEGAL_MODIFIER!>reified<!>
fun foo() {}
}
// Secondary constructors
class IllegalModifiers8 {
<!ILLEGAL_MODIFIER, INCOMPATIBLE_MODIFIERS!>abstract<!>
<!ILLEGAL_ENUM_ANNOTATION!>enum<!>
<!ILLEGAL_MODIFIER, REDUNDANT_MODIFIER, REDUNDANT_MODIFIER, INCOMPATIBLE_MODIFIERS!>open<!>
<!ILLEGAL_MODIFIER!>inner<!>
<!ILLEGAL_ANNOTATION_KEYWORD!>annotation<!>
<!ILLEGAL_MODIFIER!>override<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>in<!>
<!ILLEGAL_MODIFIER, INCOMPATIBLE_MODIFIERS!>final<!>
<!ILLEGAL_MODIFIER!>vararg<!>
<!ILLEGAL_MODIFIER!>reified<!>
constructor() {}
constructor(<!ILLEGAL_MODIFIER!>private<!> <!ILLEGAL_MODIFIER!>enum<!> <!ILLEGAL_MODIFIER!>abstract<!> <!UNUSED_PARAMETER!>x<!>: Int) {}
}
class IllegalModifiers9 {
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>protected<!> constructor() {}
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>internal<!> constructor(<!UNUSED_PARAMETER!>x<!>: Int) {}
}

View File

@@ -84,6 +84,31 @@ package illegal_modifiers {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal open class IllegalModifiers7 {
public constructor IllegalModifiers7()
internal final val x: kotlin.Int = 1
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class IllegalModifiers8 {
public constructor IllegalModifiers8()
public constructor IllegalModifiers8(/*0*/ x: kotlin.Int)
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 final class IllegalModifiers9 {
private constructor IllegalModifiers9()
private constructor IllegalModifiers9(/*0*/ x: kotlin.Int)
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 final class LegalModifier {
public constructor LegalModifier(/*0*/ a: kotlin.Int, /*1*/ illegal_modifiers.annotated() b: kotlin.String, /*2*/ illegal_modifiers.annotated() vararg v: kotlin.Int /*kotlin.IntArray*/)
internal final val a: kotlin.Int

View File

@@ -1,4 +1,4 @@
class A {
constructor() {}
constructor()
init {}
}

View File

@@ -12,6 +12,6 @@ class A {
object C {
}
constructor(x: Int) {}
constructor() : this(foo() + prop + B.bar() + B.prop + C) {}
constructor(x: Int)
constructor() : this(foo() + prop + B.bar() + B.prop + C)
}

View File

@@ -1,15 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(x: Int) {
constructor(x: Double): this(1) {}
constructor(x: String): this(1) {}
constructor(x: Double): this(1)
constructor(x: String): this(1)
}
val x1: A = A(1)
val x2: A = A(1.0)
val x3: A = A("abc")
class B<R> {
constructor(x: String) {}
constructor(x: R) {}
constructor(x: String)
constructor(x: R)
}
val y1: B<Int> = B(1)

View File

@@ -1,20 +1,20 @@
object A {
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor() {}<!>
init {}
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor()
<!>init {}
}
enum class B {
X : B() {
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor() {}<!>
}
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor()
<!>}
}
class C {
companion object {
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor() {}<!>
}
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor()
<!>}
}
val anonObject = object {
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor() {}<!>
}
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor()
<!>}

View File

@@ -1,3 +1,3 @@
trait A {
<!CONSTRUCTOR_IN_TRAIT!>constructor() {}<!>
}
<!CONSTRUCTOR_IN_TRAIT!>constructor()
<!>}

View File

@@ -3,7 +3,7 @@ annotation class Ann1
annotation class Ann2(val x: Int)
class A {
Ann1 constructor() {}
<!NO_VALUE_FOR_PARAMETER!>Ann2<!> constructor(x1: Int) {}
Ann2(2) constructor(x1: Int, x2: Int) {}
Ann1 constructor()
<!NO_VALUE_FOR_PARAMETER!>Ann2<!> constructor(x1: Int)
Ann2(2) constructor(x1: Int, x2: Int)
}

View File

@@ -1,39 +1,39 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A1 {
constructor(): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>() {}
constructor(): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>()
}
class A2(x: Byte) {
constructor(x1: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, 1) {}
constructor(x1: Int, x2: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2, 2) {}
constructor(x1: Int, x2: Int, x3: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1) {}
constructor(x1: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, 1)
constructor(x1: Int, x2: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2, 2)
constructor(x1: Int, x2: Int, x3: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1)
// delegating to previously declared cycle
constructor(x1: Double): this(1) {}
constructor(x1: Double): this(1)
// delegating to cycle declared after
constructor(x1: String): this(1L) {}
constructor(x1: String): this(1L)
constructor(x1: Long): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, 1L) {}
constructor(x1: Long, x2: Long): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2, 2L) {}
constructor(x1: Long, x2: Long, x3: Long): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1) {}
constructor(x1: Long): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, 1L)
constructor(x1: Long, x2: Long): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2, 2L)
constructor(x1: Long, x2: Long, x3: Long): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1)
// no cycle, just call to primary constuctor
constructor(x1: Double, x2: Double): this(x1, x2, 1.0) {}
constructor(x1: Double, x2: Double, x3: Double): this(x1, x2, x3, 1.0) {}
constructor(x1: Double, x2: Double, x3: Double, x4: Double): this(1.toByte()) {}
constructor(x1: Double, x2: Double): this(x1, x2, 1.0)
constructor(x1: Double, x2: Double, x3: Double): this(x1, x2, x3, 1.0)
constructor(x1: Double, x2: Double, x3: Double, x4: Double): this(1.toByte())
constructor(): this("x", "y") {}
constructor(): this("x", "y")
constructor(x1: String, x2: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2, "") {}
constructor(x1: String, x2: String, x3: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2) {}
constructor(x1: String, x2: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2, "")
constructor(x1: String, x2: String, x3: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x1, x2)
}
open class B(x: Byte)
class A : B {
// no cycle, just call to super constuctor
constructor(x1: Double, x2: Double): this(x1, x2, 1.0) {}
constructor(x1: Double, x2: Double, x3: Double): this(x1, x2, x3, 1.0) {}
constructor(x1: Double, x2: Double, x3: Double, x4: Double): super(1.toByte()) {}
constructor(x1: Double, x2: Double): this(x1, x2, 1.0)
constructor(x1: Double, x2: Double, x3: Double): this(x1, x2, x3, 1.0)
constructor(x1: Double, x2: Double, x3: Double, x4: Double): super(1.toByte())
}

View File

@@ -1,12 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
data class A1(val x: String) {
constructor(): this("") {}
constructor(): this("")
}
data class A2() {
constructor(x: String): this() {}
constructor(x: String): this()
}
data class <!PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS!>A3<!> {
constructor() {}
constructor()
}

View File

@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
constructor(x: Any, y: Any, z: Any) {}
constructor(x: Any, y: Any, z: Any)
constructor(x: String?, y: String?): this(x!!, <!DEBUG_INFO_SMARTCAST!>x<!>.length().toString() + y!!, "") {
<!DEBUG_INFO_SMARTCAST!>x<!>.length() + <!DEBUG_INFO_SMARTCAST!>y<!>.length()
}

View File

@@ -2,5 +2,5 @@ trait A
class AImpl : A
class B : <!UNSUPPORTED!>A by AImpl()<!> {
constructor() {}
constructor()
}

View File

@@ -2,24 +2,24 @@
enum class A {
W: A(1) X: A(1, 2) Y: A(3.0) Z: A("") E: A()
constructor() {}
constructor(x: Int) {}
constructor(x: Int, y: Int): this(x+y) {}
constructor(x: Double): this(x.toInt(), 1) {}
constructor(x: String): <!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR!>super<!>(x, 1) {}
constructor()
constructor(x: Int)
constructor(x: Int, y: Int): this(x+y)
constructor(x: Double): this(x.toInt(), 1)
constructor(x: String): <!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR!>super<!>(x, 1)
}
enum class B(x: Int) {
W: B(1) X: B(1, 2) Y: B(3.0) Z: B("")
constructor(x: Int, y: Int): this(x+y) {}
constructor(x: Double): this(x.toInt(), 1) {}
constructor(x: String): <!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR!>super<!>(x, 1) {}
constructor(x: Int, y: Int): this(x+y)
constructor(x: Double): this(x.toInt(), 1)
constructor(x: String): <!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR!>super<!>(x, 1)
}
enum class C {
EMPTY: C() // may be we should avoid explicit call here
constructor() {}
constructor()
}
enum class D(val prop: Int) {
@@ -33,8 +33,8 @@ enum class D(val prop: Int) {
override fun f() = prop
}
constructor(): this(1) {}
constructor(x: String): this(x.length()) {}
constructor(): this(1)
constructor(x: String): this(x.length())
abstract fun f(): Int
}

View File

@@ -0,0 +1,42 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B0(x: Int)
class A0 : B0 {
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : super(<!NO_VALUE_FOR_PARAMETER!>)<!>
}
// --------------------------
open class B1 {
constructor(x: Int = 1)
constructor()
}
class A1 : B1 {
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : <!OVERLOAD_RESOLUTION_AMBIGUITY!>super<!>()
}
// --------------------------
open class B2 {
constructor(x: Int)
constructor(x: String)
}
class A2 : B2 {
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : <!NONE_APPLICABLE!>super<!>()
}
// --------------------------
open class B3 {
private constructor()
}
class A3 : B3 {
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : <!INVISIBLE_MEMBER!>super<!>()
}

View File

@@ -0,0 +1,63 @@
package
internal final class A0 : B0 {
public constructor A0()
public constructor A0(/*0*/ x: kotlin.Int)
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 final class A1 : B1 {
public constructor A1()
public constructor A1(/*0*/ x: kotlin.Int)
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 final class A2 : B2 {
public constructor A2()
public constructor A2(/*0*/ x: kotlin.Int)
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 final class A3 : B3 {
public constructor A3()
public constructor A3(/*0*/ x: kotlin.Int)
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 open class B0 {
public constructor B0(/*0*/ x: kotlin.Int)
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 open class B1 {
public constructor B1()
public constructor B1(/*0*/ x: kotlin.Int = ...)
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 open class B2 {
public constructor B2(/*0*/ x: kotlin.Int)
public constructor B2(/*0*/ x: kotlin.String)
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 open class B3 {
private constructor B3()
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
}

View File

@@ -1,8 +1,8 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(x: Int) {
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor<!>() {}
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor()<!>
}
open class B(x: Int)
class C(x: Int) : B(x) {
constructor(): <!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>super<!>(1) {}
constructor(): <!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>super<!>(1)
}

View File

@@ -1,21 +1,21 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE
open class B<T>(x: T, y: T) {
constructor(x: T): this(x, x) {}
constructor(): this(null!!, null!!) {}
constructor(x: T): this(x, x)
constructor(): this(null!!, null!!)
}
class A0 : B<String?> {
constructor() {}
constructor(x: String): super(x) {}
constructor(x: String, y: String): super(x, y) {}
constructor()
constructor(x: String): super(x)
constructor(x: String, y: String): super(x, y)
}
class A1<R> : B<R> {
constructor() {}
constructor(x: R): super(x) {}
constructor(x: R, y: R): super(x, y) {}
constructor()
constructor(x: R): super(x)
constructor(x: R, y: R): super(x, y)
}
class A2<R> {
constructor(t: R, i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(<!TYPE_MISMATCH!>i<!>, 1) {}
constructor(t: R, i: Int) : this(<!TYPE_MISMATCH!>i<!>, 1)
}

View File

@@ -2,25 +2,25 @@
open class B<R1, R2>(x: R1, y: R2)
class A0<T1, T2> {
constructor(x: T1, y: T2): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x, y) {}
constructor(x: T1, y: T2): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x, y)
constructor(x: T1, y: T2, z: T2): this(x, 1) {} // ok, delegates to constructor(x: T1, y: Int)
constructor(x: T1, y: T2, z: T2): this(x, 1) // ok, delegates to constructor(x: T1, y: Int)
constructor(x: T1, y: Int): <!NONE_APPLICABLE!>this<!>(x, "") {}
constructor(x: T1): this(x, 1) {}
constructor(x: T1, y: T2, z: String): <!NONE_APPLICABLE!>this<!>(y, x) {}
constructor(x: T1, y: Int): <!NONE_APPLICABLE!>this<!>(x, "")
constructor(x: T1): this(x, 1)
constructor(x: T1, y: T2, z: String): <!NONE_APPLICABLE!>this<!>(y, x)
}
class A1<T1, T2> : B<T1, T2> {
constructor(x: T1, y: T2): super(x, y) {}
constructor(x: T1, y: Int): super(x, <!TYPE_MISMATCH(T2; kotlin.Int)!>y<!>) {}
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(T2; T1)!>y<!>) {}
constructor(x: T1, y: T2): super(x, y)
constructor(x: T1, y: Int): super(x, <!TYPE_MISMATCH(T2; kotlin.Int)!>y<!>)
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(T2; T1)!>y<!>)
}
class A2<T1, T2> : B<T1, Int> {
constructor(x: T1, y: T2): super(x, <!TYPE_MISMATCH(kotlin.Int; T2)!>y<!>) {}
constructor(x: T1, y: Int): super(x, y) {}
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(kotlin.Int; T1)!>y<!>) {}
constructor(x: T1, y: T2, z: String): super(<!TYPE_MISMATCH(T1; T2)!>y<!>, 1) {}
constructor(x: T1, y: T2): super(x, <!TYPE_MISMATCH(kotlin.Int; T2)!>y<!>)
constructor(x: T1, y: Int): super(x, y)
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(kotlin.Int; T1)!>y<!>)
constructor(x: T1, y: T2, z: String): super(<!TYPE_MISMATCH(T1; T2)!>y<!>, 1)
}

View File

@@ -1,16 +1,16 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B<X, Y : X> {
constructor(x: X, y: Y) {}
constructor(x: X, s: String) {}
constructor(y: Y, i: Int) : this(y, "") {}
constructor(x: X, y: Y)
constructor(x: X, s: String)
constructor(y: Y, i: Int) : this(y, "")
}
class A<T1, T2 : T1> : B<T1, T2> {
constructor(x: T1, y: T2): super(x, y) {}
constructor(x: T2, y: T2, z: String): super(x, y) {}
constructor(x: T1, y: T2): super(x, y)
constructor(x: T2, y: T2, z: String): super(x, y)
constructor(x: T2, z: String, z1: String): super(x, "") {}
constructor(x: T2, z: String, z1: String, z2: String): super(x, 1) {}
constructor(x: T1, z: String, z1: String, z2: String, z3: String): super(x, "") {}
constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): <!NONE_APPLICABLE!>super<!>(x, 1) {}
constructor(x: T2, z: String, z1: String): super(x, "")
constructor(x: T2, z: String, z1: String, z2: String): super(x, 1)
constructor(x: T1, z: String, z1: String, z2: String, z3: String): super(x, "")
constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): <!NONE_APPLICABLE!>super<!>(x, 1)
}

View File

@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B(x: Int)
class A : <!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>B(1)<!> {
constructor(): super(1) {}
constructor(): super(1)
}

View File

@@ -11,5 +11,5 @@ class A {
}
}
class A1(val x: Int, val y: Int) {
constructor(other: A1): this(other.x, other.y) {}
constructor(other: A1): this(other.x, other.y)
}

View File

@@ -1,3 +1,3 @@
class X<T>(val t: T) {
constructor(t: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(t) {}
constructor(t: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(t)
}

View File

@@ -1,5 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class X<T>(val t: T) {
constructor(t: T, i: Int) : <!NONE_APPLICABLE!>this<!>(i) {
}
constructor(t: T, i: Int) : <!NONE_APPLICABLE!>this<!>(i)
}

View File

@@ -1,5 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class X<T> {
constructor(t: T, i: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(<!TYPE_MISMATCH!>i<!>, 1) { // no error
}
constructor(t: T, i: Int): this(<!TYPE_MISMATCH!>i<!>, 1)
}

View File

@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A<T1, T2> {
constructor(block: (T1) -> T2) {}
constructor(x: T2): this({ x }) {}
constructor(block: (T1) -> T2)
constructor(x: T2): this({ x })
}

View File

@@ -3,11 +3,11 @@ open class B(open val parentProperty: String)
class A : B {
val myProp: String = ""
override val parentProperty: String = ""
constructor(arg: String = <!UNRESOLVED_REFERENCE!>myProp<!>): super(<!UNRESOLVED_REFERENCE!>myProp<!>) {}
constructor(x1: String, arg: String = <!NO_THIS!>this<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>myProp<!>): super(<!NO_THIS!>this<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>myProp<!>) {}
constructor(x1: String, x2: String, arg: String = <!UNRESOLVED_REFERENCE!>parentProperty<!>): super(<!UNRESOLVED_REFERENCE!>parentProperty<!>) {}
constructor(x1: String, x2: String, x3: String, arg: String = <!SUPER_NOT_AVAILABLE!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>parentProperty<!>): super(<!SUPER_NOT_AVAILABLE!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>parentProperty<!>) {}
constructor(x1: String, x2: String, x3: String, x4: String, arg: String = foo(<!NO_THIS!>this<!>)): super(foo(<!NO_THIS!>this<!>)) {}
constructor(x1: String, x2: String, x3: String, x4: String, x5: String, arg: String = foo(this<!UNRESOLVED_REFERENCE!>@A<!>)): super(foo(this<!UNRESOLVED_REFERENCE!>@A<!>)) {}
constructor(arg: String = <!UNRESOLVED_REFERENCE!>myProp<!>): super(<!UNRESOLVED_REFERENCE!>myProp<!>)
constructor(x1: String, arg: String = <!NO_THIS!>this<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>myProp<!>): super(<!NO_THIS!>this<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>myProp<!>)
constructor(x1: String, x2: String, arg: String = <!UNRESOLVED_REFERENCE!>parentProperty<!>): super(<!UNRESOLVED_REFERENCE!>parentProperty<!>)
constructor(x1: String, x2: String, x3: String, arg: String = <!SUPER_NOT_AVAILABLE!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>parentProperty<!>): super(<!SUPER_NOT_AVAILABLE!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>parentProperty<!>)
constructor(x1: String, x2: String, x3: String, x4: String, arg: String = foo(<!NO_THIS!>this<!>)): super(foo(<!NO_THIS!>this<!>))
constructor(x1: String, x2: String, x3: String, x4: String, x5: String, arg: String = foo(this<!UNRESOLVED_REFERENCE!>@A<!>)): super(foo(this<!UNRESOLVED_REFERENCE!>@A<!>))
}
fun foo(x: A) = ""

View File

@@ -0,0 +1,7 @@
class A {
open inner class Inner
class Nested : Inner {
<!INACCESSIBLE_OUTER_CLASS_EXPRESSION!>constructor()<!>
}
}

View File

@@ -0,0 +1,22 @@
package
internal final class A {
public constructor A()
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 open inner class Inner {
public constructor Inner()
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 final class Nested : A.Inner {
public constructor Nested()
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
}
}

View File

@@ -1,4 +1,4 @@
// do not report generate empty synthetic constructor by primary as it leads to CONFLICTING_JVM_DECLARATIONS
class A(val x: Int = 1, val y: Int = 2) {
constructor(): this(0, 0) {}
constructor(): this(0, 0)
}

View File

@@ -1,8 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
constructor(x: Int) {
}
constructor(x: Int)
}
val x = A(<!NO_VALUE_FOR_PARAMETER!>)<!>

View File

@@ -2,5 +2,5 @@ open class B
trait C
trait D
class A : C, B, D {
constructor() {}
constructor()
}

View File

@@ -1,27 +1,26 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class <!CONFLICTING_OVERLOADS!>A(x: String = "", y: String = "")<!> {
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y) {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y)
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
}
class B {
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!> {}
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!>
}
<!CONFLICTING_OVERLOADS!>fun B(x: Int)<!> {}
class Outer {
class <!CONFLICTING_OVERLOADS!>A(x: String = "", y: String = "")<!> {
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y) {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y)
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
}
class B {
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!> {
}
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!>
}
<!CONFLICTING_OVERLOADS!>fun B(x: Int)<!> {}

View File

@@ -1,11 +1,11 @@
class <!REDECLARATION!>A<!>
class <!REDECLARATION!>A<!> {
constructor() {}
constructor()
}
class B
class Outer {
class B {
constructor() {}
constructor()
}
}

View File

@@ -1,4 +1,4 @@
class A {
val prop: Int = <!TYPE_MISMATCH!>""<!>
constructor() {}
constructor()
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
constructor(): super(<!TOO_MANY_ARGUMENTS!>1<!>) { }
constructor(): super(<!TOO_MANY_ARGUMENTS!>1<!>)
}

View File

@@ -1,10 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B(x: Double) {
constructor(x: Int): this(1.0) {}
constructor(x: String): this(1.0) {}
constructor(x: Int): this(1.0)
constructor(x: String): this(1.0)
}
trait C
class A : B, C {
constructor(): <!NONE_APPLICABLE!>super<!>(' ') { }
<!NONE_APPLICABLE!>constructor<!>(x: Int) { }
constructor(): <!NONE_APPLICABLE!>super<!>(' ')
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor(x: Int)<!>
}

View File

@@ -3,5 +3,5 @@ class A {
constructor(
<!VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER!>val<!> x: Int, y: Int,
<!VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER!>var<!> z: Int,
<!ILLEGAL_MODIFIER!>public<!> a: Int) {}
<!ILLEGAL_MODIFIER!>public<!> a: Int)
}

View File

@@ -2,11 +2,11 @@
fun <T> array(vararg x: T): Array<T> = null!!
open class B(vararg y: String) {
constructor(x: Int): this(x.toString(), *array("1"), "2") {}
constructor(x: Int): this(x.toString(), *array("1"), "2")
}
class A : B {
constructor(x: String, y: String): super(x, *array("3"), y) {}
constructor(x: String): super(x) {}
constructor(): super() {}
constructor(x: String, y: String): super(x, *array("3"), y)
constructor(x: String): super(x)
constructor(): super()
}

View File

@@ -2,13 +2,13 @@
fun <T> array(vararg x: T): Array<T> = null!!
open class B(x: Int) {
constructor(vararg y: String): this(y[0].length()) {}
constructor(vararg y: String): this(y[0].length())
}
class A : B {
constructor(x: String, y: String): super(x, *array("q"), y) {}
constructor(x: String): super(x) {}
constructor(): super() {}
constructor(x: String, y: String): super(x, *array("q"), y)
constructor(x: String): super(x)
constructor(): super()
}
val b1 = B()

View File

@@ -1,3 +1,4 @@
// !DIAGNOSTICS: -NON_TOPLEVEL_CLASS_DECLARATION
// !MARK_DYNAMIC_CALLS
fun test(d: dynamic) {
@@ -97,4 +98,4 @@ fun test(d: dynamic) {
val dyn: dynamic = null
val foo : Int <!DEBUG_INFO_DYNAMIC, DEBUG_INFO_DYNAMIC!>by dyn<!>
var bar : Int <!DEBUG_INFO_DYNAMIC, DEBUG_INFO_DYNAMIC, DEBUG_INFO_DYNAMIC!>by dyn<!>
var bar : Int <!DEBUG_INFO_DYNAMIC, DEBUG_INFO_DYNAMIC, DEBUG_INFO_DYNAMIC!>by dyn<!>

View File

@@ -1,7 +1,9 @@
// !DIAGNOSTICS: -NON_TOPLEVEL_CLASS_DECLARATION
val foo: dynamic = 1
fun foo() {
class C {
val foo: dynamic = 1
}
}
}

View File

@@ -0,0 +1,16 @@
fun test() {
js(<!JSCODE_NO_JAVASCRIPT_PRODUCED!>""<!>)
js(<!JSCODE_NO_JAVASCRIPT_PRODUCED!>" "<!>)
js(<!JSCODE_NO_JAVASCRIPT_PRODUCED!>"""
"""<!>)
val empty = ""
js(<!JSCODE_NO_JAVASCRIPT_PRODUCED!>empty<!>)
val whitespace = " "
js(<!JSCODE_NO_JAVASCRIPT_PRODUCED!>whitespace<!>)
val multiline = """
"""
js(<!JSCODE_NO_JAVASCRIPT_PRODUCED!>multiline<!>)
}

View File

@@ -0,0 +1,3 @@
package
internal fun test(): kotlin.Unit

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION
fun foo() {
class A {
@@ -42,4 +42,4 @@ fun foo() {
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>nativeGetter
fun baz(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: Int = 0<!>): Int?<!> = 0
}
}
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION
fun foo() {
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN, NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>[nativeGetter]

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION
class A {
class B {
@@ -109,4 +109,4 @@ class A {
fun baz(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: String = "foo"<!>): Int?<!> = 0
}
}
}
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION
fun foo() {
class A {
@@ -22,4 +22,4 @@ fun foo() {
fun invoke(a: String): Int<!> = 0
}
}
}
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION
fun foo() {
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>[nativeInvoke]

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION
class A {
class B {
@@ -40,4 +40,4 @@ class A {
fun invoke(a: String): Int<!> = 0
}
}
}
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION
fun foo() {
class A {
@@ -42,4 +42,4 @@ fun foo() {
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>[nativeSetter]
fun foo(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: Int = 0<!>, v: String)<!> = "OK"
}
}
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION
fun foo() {
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN, NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>[nativeSetter]
@@ -9,4 +9,4 @@ fun foo() {
[nativeSetter]
class <!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>Foo<!> {}
}
}

View File

@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION
class A {
class B {
@@ -127,4 +127,4 @@ class A {
fun foo(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: Number = 0.0<!>, v: String)<!> = "OK"
}
}
}
}

View File

@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
fun foo() {
<!NON_TOPLEVEL_CLASS_DECLARATION!>class A<!> {
inner <!NON_TOPLEVEL_CLASS_DECLARATION!>class E<!> {
<!NESTED_CLASS_NOT_ALLOWED, NON_TOPLEVEL_CLASS_DECLARATION!>trait T<!>
}
}
<!NON_TOPLEVEL_CLASS_DECLARATION!>trait T<!> {
}
}

View File

@@ -0,0 +1,3 @@
package
internal fun foo(): kotlin.Unit

Some files were not shown because too many files have changed in this diff Show More