[FIR] Add NO_THIS & INSTANCE_ACCESS_BEFORE_SUPER_CALL

This commit is contained in:
Nick
2020-08-17 17:21:46 +03:00
parent 7e1c2cfd36
commit c8f8908a01
86 changed files with 526 additions and 219 deletions
@@ -14,4 +14,4 @@ fun A.test_2() {
object : B by b {} object : B by b {}
} }
class D(val x: String, val y: String = this.<!UNRESOLVED_REFERENCE!>x<!>) {} class D(val x: String, val y: String = <!NO_THIS!>this<!>.<!UNRESOLVED_REFERENCE!>x<!>) {}
@@ -0,0 +1,50 @@
class A {
constructor(x: Int = <!UNRESOLVED_REFERENCE!>getSomeInt<!>(), other: A = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>, header: String = <!UNRESOLVED_REFERENCE!>keker<!>) {}
fun getSomeInt() = 10
var keker = "test"
}
class B(other: B = <!NO_THIS!>this<!>)
class C() {
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>this<!>({
val a = 10
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
}) {}
}
class D {
var a = 20
constructor() {
this.a = 10
}
}
fun main() {
val x1: String.() -> String = if (true) {
{ <!NO_THIS!>this<!> }
} else {
{ <!NO_THIS!>this<!> }
}
}
fun test(f: F) {}
val a = <!NO_THIS!>this<!>
class F(var a: Int, b: Int, closure: () -> Unit, instance: F?) {
constructor(x: Int) : this(x, x, {
val a = 10
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
test(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>)
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>a<!> = 20
}, <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) {
this.a = 30
}
}
open class Base(val x: Int)
class Derived : Base(<!NO_THIS!>this<!>.<!UNRESOLVED_REFERENCE!>y<!>) { // FE 1.0 reports NO_THIS here
val y = 42
}
@@ -0,0 +1,106 @@
FILE: instanceAccessBeforeSuperCall.kt
public final class A : R|kotlin/Any| {
public constructor(x: R|kotlin/Int| = <Unresolved name: getSomeInt>#(), other: R|A| = this@R|/A|, header: R|kotlin/String| = <Unresolved name: keker>#): R|A| {
super<R|kotlin/Any|>()
}
public final fun getSomeInt(): R|kotlin/Int| {
^getSomeInt Int(10)
}
public final var keker: R|kotlin/String| = String(test)
public get(): R|kotlin/String|
public set(value: R|kotlin/String|): R|kotlin/Unit|
}
public final class B : R|kotlin/Any| {
public constructor(other: R|B| = this#): R|B| {
super<R|kotlin/Any|>()
}
}
public final class C : R|kotlin/Any| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
public constructor(x: R|kotlin/Int|): R|C| {
this<R|C|>(fun <anonymous>(): R|ERROR CLASS: Cannot access ''<this>'' before superclass constructor has been called| {
lval a: R|kotlin/Int| = Int(10)
^ this@R|/C|
}
)
}
}
public final class D : R|kotlin/Any| {
public final var a: R|kotlin/Int| = Int(20)
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
public constructor(): R|D| {
super<R|kotlin/Any|>()
this@R|/D|.R|/D.a| = Int(10)
}
}
public final fun main(): R|kotlin/Unit| {
lval x1: R|kotlin/String.() -> kotlin/String| = when () {
Boolean(true) -> {
fun <anonymous>(it: R|kotlin/String|): R|ERROR CLASS: 'this' is not defined in this context| {
^ this#
}
}
else -> {
fun <anonymous>(it: R|kotlin/String|): R|ERROR CLASS: 'this' is not defined in this context| {
^ this#
}
}
}
}
public final fun test(f: R|F|): R|kotlin/Unit| {
}
public final val a: R|ERROR CLASS: 'this' is not defined in this context| = this#
public get(): R|ERROR CLASS: 'this' is not defined in this context|
public final class F : R|kotlin/Any| {
public constructor(a: R|kotlin/Int|, b: R|kotlin/Int|, closure: R|() -> kotlin/Unit|, instance: R|F?|): R|F| {
super<R|kotlin/Any|>()
}
public final var a: R|kotlin/Int| = R|<local>/a|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
public constructor(x: R|kotlin/Int|): R|F| {
this<R|F|>(R|<local>/x|, R|<local>/x|, fun <anonymous>(): R|kotlin/Unit| {
lval a: R|kotlin/Int| = Int(10)
this@R|/F|
R|/test|(this@R|/F|)
this@R|/F|.<Unresolved name: a># = Int(20)
}
, this@R|/F|)
this@R|/F|.R|/F.a| = Int(30)
}
}
public open class Base : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|Base| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public final class Derived : R|Base| {
public constructor(): R|Derived| {
super<R|Base|>(this#.<Unresolved name: y>#)
}
public final val y: R|kotlin/Int| = Int(42)
public get(): R|kotlin/Int|
}
@@ -36,7 +36,7 @@ FILE: access.kt
^plus String() ^plus String()
} }
public final fun R|Foo|.check(): <ERROR TYPE REF: Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]> { public final fun R|Foo|.check(): R|ERROR CLASS: Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]| {
^check this@R|/Bar.check|.R|/Foo.abc|().<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|/Bar|.R|/Bar.bar|()) ^check this@R|/Bar.check|.R|/Foo.abc|().<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|/Bar|.R|/Bar.bar|())
} }
@@ -2,7 +2,7 @@
fun x() {} fun x() {}
operator fun Int.invoke(): Foo = this@Foo operator fun Int.invoke(): Foo = <!UNRESOLVED_LABEL!>this@Foo<!>
class Foo { class Foo {
@@ -11,6 +11,6 @@ FILE: implicitTypes.kt
public final fun loop1(): R|(kotlin/Any?) -> kotlin/Nothing| { public final fun loop1(): R|(kotlin/Any?) -> kotlin/Nothing| {
^loop1 <Inapplicable(INAPPLICABLE): /use>#<R|kotlin/Any?|, R|kotlin/Nothing|>(::<Unresolved reference: loop2>#) ^loop1 <Inapplicable(INAPPLICABLE): /use>#<R|kotlin/Any?|, R|kotlin/Nothing|>(::<Unresolved reference: loop2>#)
} }
public final fun loop2(): <ERROR TYPE REF: cycle> { public final fun loop2(): R|ERROR CLASS: cycle| {
^loop2 R|/loop1|() ^loop2 R|/loop1|()
} }
@@ -976,6 +976,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/infixFunctions.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/infixFunctions.kt");
} }
@TestMetadata("instanceAccessBeforeSuperCall.kt")
public void testInstanceAccessBeforeSuperCall() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt");
}
@TestMetadata("interfaceWithSuperclass.kt") @TestMetadata("interfaceWithSuperclass.kt")
public void testInterfaceWithSuperclass() throws Exception { public void testInterfaceWithSuperclass() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/interfaceWithSuperclass.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/interfaceWithSuperclass.kt");
@@ -976,6 +976,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/infixFunctions.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/infixFunctions.kt");
} }
@TestMetadata("instanceAccessBeforeSuperCall.kt")
public void testInstanceAccessBeforeSuperCall() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt");
}
@TestMetadata("interfaceWithSuperclass.kt") @TestMetadata("interfaceWithSuperclass.kt")
public void testInterfaceWithSuperclass() throws Exception { public void testInterfaceWithSuperclass() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/interfaceWithSuperclass.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/interfaceWithSuperclass.kt");
@@ -6,19 +6,24 @@
package org.jetbrains.kotlin.fir.analysis.collectors package org.jetbrains.kotlin.fir.analysis.collectors
import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.checkers.context.PersistentCheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.context.PersistentCheckerContext
import org.jetbrains.kotlin.fir.analysis.collectors.components.* import org.jetbrains.kotlin.fir.analysis.collectors.components.*
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic
import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.SessionHolder import org.jetbrains.kotlin.fir.resolve.SessionHolder
import org.jetbrains.kotlin.fir.resolve.collectImplicitReceivers import org.jetbrains.kotlin.fir.resolve.collectImplicitReceivers
import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.resolve.defaultType
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.types.coneTypeSafe
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
@@ -46,8 +51,6 @@ abstract class AbstractDiagnosticCollector(
@Suppress("LeakingThis") @Suppress("LeakingThis")
private var context = PersistentCheckerContext(this) private var context = PersistentCheckerContext(this)
private var lastExpression: FirExpression? = null
fun initializeComponents(vararg components: AbstractDiagnosticCollectorComponent) { fun initializeComponents(vararg components: AbstractDiagnosticCollectorComponent) {
if (componentsInitialized) { if (componentsInitialized) {
throw IllegalStateException() throw IllegalStateException()
@@ -120,8 +123,10 @@ abstract class AbstractDiagnosticCollector(
} }
override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: Nothing?) { override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: Nothing?) {
val property = context.containingDeclarations.last() as FirProperty if (propertyAccessor !is FirDefaultPropertyAccessor) {
visitWithDeclarationAndReceiver(propertyAccessor, property.name, property.receiverTypeRef) val property = context.containingDeclarations.last() as FirProperty
visitWithDeclarationAndReceiver(propertyAccessor, property.name, property.receiverTypeRef)
}
} }
override fun visitValueParameter(valueParameter: FirValueParameter, data: Nothing?) { override fun visitValueParameter(valueParameter: FirValueParameter, data: Nothing?) {
@@ -140,33 +145,13 @@ abstract class AbstractDiagnosticCollector(
visitWithDeclaration(anonymousInitializer) visitWithDeclaration(anonymousInitializer)
} }
override fun visitExpression(expression: FirExpression, data: Nothing?) {
expression.runComponents()
withExpression(expression) {
expression.acceptChildren(this, null)
}
}
override fun visitBlock(block: FirBlock, data: Nothing?) { override fun visitBlock(block: FirBlock, data: Nothing?) {
visitExpression(block, data) visitExpression(block, data)
} }
override fun visitTypeRef(typeRef: FirTypeRef, data: Nothing?) { override fun visitTypeRef(typeRef: FirTypeRef, data: Nothing?) {
if (typeRef === lastExpression?.typeRef) { if (typeRef.source != null && typeRef.source?.kind !is FirFakeSourceElementKind) {
return super.visitTypeRef(typeRef, null)
}
super.visitTypeRef(typeRef, null)
}
override fun visitTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall, data: Nothing?) {
typeOperatorCall.runComponents()
withExpression(typeOperatorCall) {
typeOperatorCall.acceptChildren(this, null)
}
if (typeOperatorCall.operation == FirOperation.AS) {
// NB: in this case conversionTypeRef === typeRef, so we *should* visit it explicitly
typeOperatorCall.conversionTypeRef.runComponents()
typeOperatorCall.conversionTypeRef.acceptChildren(this, null)
} }
} }
@@ -201,16 +186,6 @@ abstract class AbstractDiagnosticCollector(
} }
} }
private inline fun <R> withExpression(expression: FirExpression, block: () -> R): R {
val previousExpression = lastExpression
lastExpression = expression
try {
return block()
} finally {
lastExpression = previousExpression
}
}
private inline fun <R> withLabelAndReceiverType( private inline fun <R> withLabelAndReceiverType(
labelName: Name?, labelName: Name?,
owner: FirDeclaration, owner: FirDeclaration,
@@ -33,18 +33,6 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
} }
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: CheckerContext) { override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: CheckerContext) {
when (val lastContainingDeclaration = data.containingDeclarations.lastOrNull()) {
is FirDefaultPropertyAccessor -> {
// It always uses the same type ref as the corresponding property
return
}
else -> if (
errorTypeRef.source?.kind is FirFakeSourceElementKind ||
lastContainingDeclaration?.source?.kind is FirFakeSourceElementKind
) {
return
}
}
val source = errorTypeRef.source ?: return val source = errorTypeRef.source ?: return
runCheck { reportFirDiagnostic(errorTypeRef.diagnostic, source, it) } runCheck { reportFirDiagnostic(errorTypeRef.diagnostic, source, it) }
} }
@@ -90,13 +78,12 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
is ConeIllegalAnnotationError -> FirErrors.NOT_AN_ANNOTATION_CLASS.on(source, diagnostic.name.asString()) is ConeIllegalAnnotationError -> FirErrors.NOT_AN_ANNOTATION_CLASS.on(source, diagnostic.name.asString())
is ConeWrongNumberOfTypeArgumentsError -> is ConeWrongNumberOfTypeArgumentsError ->
FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(source, diagnostic.desiredCount, diagnostic.type) FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(source, diagnostic.desiredCount, diagnostic.type)
is ConeSimpleDiagnostic -> if (source.kind is FirFakeSourceElementKind) { is ConeSimpleDiagnostic -> when {
null source.kind is FirFakeSourceElementKind -> null
} else if (diagnostic.kind == SymbolNotFound) { diagnostic.kind == SymbolNotFound -> FirErrors.UNRESOLVED_REFERENCE.on(source, "<No name>")
FirErrors.UNRESOLVED_REFERENCE.on(source, "<No name>") else -> diagnostic.getFactory().on(source)
} else {
diagnostic.getFactory().on(source)
} }
is ConeInstanceAccessBeforeSuperCall -> FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL.on(source, diagnostic.target)
is ConeStubDiagnostic -> null is ConeStubDiagnostic -> null
is ConeIntermediateDiagnostic -> null is ConeIntermediateDiagnostic -> null
else -> throw IllegalArgumentException("Unsupported diagnostic type: ${diagnostic.javaClass}") else -> throw IllegalArgumentException("Unsupported diagnostic type: ${diagnostic.javaClass}")
@@ -110,6 +97,7 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
Syntax -> FirErrors.SYNTAX_ERROR Syntax -> FirErrors.SYNTAX_ERROR
ReturnNotAllowed -> FirErrors.RETURN_NOT_ALLOWED ReturnNotAllowed -> FirErrors.RETURN_NOT_ALLOWED
UnresolvedLabel -> FirErrors.UNRESOLVED_LABEL UnresolvedLabel -> FirErrors.UNRESOLVED_LABEL
NoThis -> FirErrors.NO_THIS
IllegalConstExpression -> FirErrors.ILLEGAL_CONST_EXPRESSION IllegalConstExpression -> FirErrors.ILLEGAL_CONST_EXPRESSION
IllegalUnderscore -> FirErrors.ILLEGAL_UNDERSCORE IllegalUnderscore -> FirErrors.ILLEGAL_UNDERSCORE
DeserializationError -> FirErrors.DESERIALIZATION_ERROR DeserializationError -> FirErrors.DESERIALIZATION_ERROR
@@ -53,6 +53,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_INFI
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_LATEINIT_MODIFIER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_LATEINIT_MODIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCOMPATIBLE_MODIFIERS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCOMPATIBLE_MODIFIERS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INTERFACE_WITH_SUPERCLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INTERFACE_WITH_SUPERCLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.LEAKED_IN_PLACE_LAMBDA import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.LEAKED_IN_PLACE_LAMBDA
@@ -67,6 +68,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_CONST
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_AN_ANNOTATION_CLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_AN_ANNOTATION_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_A_LOOP_LABEL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_A_LOOP_LABEL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_A_SUPERTYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_A_SUPERTYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_THIS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_TYPE_FOR_TYPE_PARAMETER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_TYPE_FOR_TYPE_PARAMETER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NULLABLE_TYPE_OF_ANNOTATION_MEMBER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NULLABLE_TYPE_OF_ANNOTATION_MEMBER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.OTHER_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.OTHER_ERROR
@@ -145,11 +147,17 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(ERROR_FROM_JAVA_RESOLUTION, "Java resolution error") map.put(ERROR_FROM_JAVA_RESOLUTION, "Java resolution error")
// map.put(UNKNOWN_CALLABLE_KIND, ...) // & // map.put(UNKNOWN_CALLABLE_KIND, ...) // &
// map.put(MISSING_STDLIB_CLASS, ...) // & // map.put(MISSING_STDLIB_CLASS, ...) // &
map.put(NO_THIS, "'this' is not defined in this context")
// Super // Super
map.put(SUPER_IS_NOT_AN_EXPRESSION, "Super cannot be a callee") map.put(SUPER_IS_NOT_AN_EXPRESSION, "Super cannot be a callee")
map.put(SUPER_NOT_AVAILABLE, "No supertypes are accessible in this context") map.put(SUPER_NOT_AVAILABLE, "No supertypes are accessible in this context")
map.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly") map.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly")
map.put(
INSTANCE_ACCESS_BEFORE_SUPER_CALL,
"Cannot access ''{0}'' before superclass constructor has been called",
TO_STRING
)
// Supertypes // Supertypes
map.put(TYPE_PARAMETER_AS_SUPERTYPE, "Type parameter as supertype") map.put(TYPE_PARAMETER_AS_SUPERTYPE, "Type parameter as supertype")
@@ -46,11 +46,13 @@ object FirErrors {
val ERROR_FROM_JAVA_RESOLUTION by error0<FirSourceElement, PsiElement>() val ERROR_FROM_JAVA_RESOLUTION by error0<FirSourceElement, PsiElement>()
val UNKNOWN_CALLABLE_KIND by error0<FirSourceElement, PsiElement>() val UNKNOWN_CALLABLE_KIND by error0<FirSourceElement, PsiElement>()
val MISSING_STDLIB_CLASS by error0<FirSourceElement, PsiElement>() val MISSING_STDLIB_CLASS by error0<FirSourceElement, PsiElement>()
val NO_THIS by error0<FirSourceElement, PsiElement>()
// Super // Super
val SUPER_IS_NOT_AN_EXPRESSION by error0<FirSourceElement, PsiElement>() val SUPER_IS_NOT_AN_EXPRESSION by error0<FirSourceElement, PsiElement>()
val SUPER_NOT_AVAILABLE by error0<FirSourceElement, PsiElement>() val SUPER_NOT_AVAILABLE by error0<FirSourceElement, PsiElement>()
val ABSTRACT_SUPER_CALL by error0<FirSourceElement, PsiElement>() val ABSTRACT_SUPER_CALL by error0<FirSourceElement, PsiElement>()
val INSTANCE_ACCESS_BEFORE_SUPER_CALL by error1<FirSourceElement, PsiElement, String>()
// Supertypes // Supertypes
val TYPE_PARAMETER_AS_SUPERTYPE by error0<FirSourceElement, PsiElement>() val TYPE_PARAMETER_AS_SUPERTYPE by error0<FirSourceElement, PsiElement>()
@@ -711,7 +711,7 @@ class DeclarationsConverter(
val defaultVisibility = classWrapper.defaultConstructorVisibility() val defaultVisibility = classWrapper.defaultConstructorVisibility()
val firDelegatedCall = buildDelegatedConstructorCall { val firDelegatedCall = buildDelegatedConstructorCall {
source = delegatedConstructorSource ?: selfTypeSource?.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall) source = delegatedConstructorSource ?: selfTypeSource?.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall)
constructedTypeRef = classWrapper.delegatedSuperTypeRef constructedTypeRef = classWrapper.delegatedSuperTypeRef.copyWithNewSourceKind(FirFakeSourceElementKind.ImplicitTypeRef)
isThis = false isThis = false
extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode) extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode)
} }
@@ -845,7 +845,7 @@ class DeclarationsConverter(
} else { } else {
constructorDelegationCall.toFirSourceElement() constructorDelegationCall.toFirSourceElement()
} }
constructedTypeRef = delegatedType constructedTypeRef = delegatedType.copyWithNewSourceKind(FirFakeSourceElementKind.ImplicitTypeRef)
this.isThis = isThis this.isThis = isThis
extractArgumentsFrom(firValueArguments, stubMode) extractArgumentsFrom(firValueArguments, stubMode)
} }
@@ -5,7 +5,9 @@
package org.jetbrains.kotlin.fir.lightTree.fir package org.jetbrains.kotlin.fir.lightTree.fir
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.copyWithNewSourceKind
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirProperty
import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter
@@ -46,7 +48,7 @@ class ValueParameter(
source = firValueParameter.source source = firValueParameter.source
this.session = session this.session = session
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
returnTypeRef = type returnTypeRef = type.copyWithNewSourceKind(FirFakeSourceElementKind.ImplicitTypeRef)
this.name = name this.name = name
initializer = buildQualifiedAccessExpression { initializer = buildQualifiedAccessExpression {
calleeReference = buildPropertyFromParameterResolvedNamedReference { calleeReference = buildPropertyFromParameterResolvedNamedReference {
@@ -383,7 +383,7 @@ class RawFirBuilder(
source = propertySource source = propertySource
session = baseSession session = baseSession
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
returnTypeRef = type returnTypeRef = type.copyWithNewSourceKind(FirFakeSourceElementKind.PropertyFromParameter)
receiverTypeRef = null receiverTypeRef = null
name = propertyName name = propertyName
initializer = buildQualifiedAccessExpression { initializer = buildQualifiedAccessExpression {
@@ -597,7 +597,7 @@ class RawFirBuilder(
?: owner.toFirPsiSourceElement(FirFakeSourceElementKind.ImplicitConstructor) ?: owner.toFirPsiSourceElement(FirFakeSourceElementKind.ImplicitConstructor)
val firDelegatedCall = buildDelegatedConstructorCall { val firDelegatedCall = buildDelegatedConstructorCall {
source = constructorCallee ?: constructorSource.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall) source = constructorCallee ?: constructorSource.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall)
constructedTypeRef = delegatedSuperTypeRef constructedTypeRef = delegatedSuperTypeRef.copyWithNewSourceKind(FirFakeSourceElementKind.ImplicitTypeRef)
isThis = false isThis = false
if (!stubMode) { if (!stubMode) {
superTypeCallEntry?.extractArgumentsTo(this) superTypeCallEntry?.extractArgumentsTo(this)
@@ -1112,7 +1112,7 @@ class RawFirBuilder(
} }
return buildDelegatedConstructorCall { return buildDelegatedConstructorCall {
this.source = source this.source = source
constructedTypeRef = delegatedType constructedTypeRef = delegatedType.copyWithNewSourceKind(FirFakeSourceElementKind.ImplicitTypeRef)
this.isThis = isThis this.isThis = isThis
if (!stubMode) { if (!stubMode) {
extractArgumentsTo(this) extractArgumentsTo(this)
@@ -1834,11 +1834,11 @@ class RawFirBuilder(
override fun visitSuperExpression(expression: KtSuperExpression, data: Unit): FirElement { override fun visitSuperExpression(expression: KtSuperExpression, data: Unit): FirElement {
val superType = expression.superTypeQualifier val superType = expression.superTypeQualifier
val source = expression.toFirSourceElement() val theSource = expression.toFirSourceElement()
return buildQualifiedAccessExpression { return buildQualifiedAccessExpression {
this.source = source this.source = theSource
calleeReference = buildExplicitSuperReference { calleeReference = buildExplicitSuperReference {
source.fakeElement(FirFakeSourceElementKind.ExplicitThisOrSuperReference) source = theSource.fakeElement(FirFakeSourceElementKind.ExplicitThisOrSuperReference)
labelName = expression.getLabelName() labelName = expression.getLabelName()
superTypeRef = superType.toFirOrImplicitType() superTypeRef = superType.toFirOrImplicitType()
} }
@@ -351,9 +351,14 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol<
if (makeNullable) { if (makeNullable) {
returnTypeRef.withReplacedConeType( returnTypeRef.withReplacedConeType(
returnTypeRef.type.withNullability(ConeNullability.NULLABLE, session.typeContext), returnTypeRef.type.withNullability(ConeNullability.NULLABLE, session.typeContext),
FirFakeSourceElementKind.ImplicitTypeRef
) )
} else { } else {
returnTypeRef buildResolvedTypeRef {
source = returnTypeRef.source?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)
type = returnTypeRef.type
annotations += returnTypeRef.annotations
}
} }
} }
is FirClassifierSymbol<*> -> { is FirClassifierSymbol<*> -> {
@@ -121,3 +121,18 @@ class ImplicitExtensionReceiverValue(
useSiteSession: FirSession, useSiteSession: FirSession,
scopeSession: ScopeSession scopeSession: ScopeSession
) : ImplicitReceiverValue<FirCallableSymbol<*>>(boundSymbol, type, useSiteSession, scopeSession) ) : ImplicitReceiverValue<FirCallableSymbol<*>>(boundSymbol, type, useSiteSession, scopeSession)
class InaccessibleImplicitReceiverValue internal constructor(
boundSymbol: FirClassSymbol<*>,
type: ConeKotlinType,
useSiteSession: FirSession,
scopeSession: ScopeSession
) : ImplicitReceiverValue<FirClassSymbol<*>>(boundSymbol, type, useSiteSession, scopeSession) {
internal constructor(
boundSymbol: FirClassSymbol<*>, useSiteSession: FirSession, scopeSession: ScopeSession
) : this(
boundSymbol, boundSymbol.constructType(typeArguments = emptyArray(), isNullable = false),
useSiteSession, scopeSession
)
}
@@ -364,8 +364,12 @@ class FirTowerResolverSession internal constructor(
onScope(lexical.scope, parentGroup.NonLocal(depth)) onScope(lexical.scope, parentGroup.NonLocal(depth))
} }
lexical.implicitReceiver?.let { implicitReceiverValue -> val receiver = lexical.implicitReceiver
onImplicitReceiver(implicitReceiverValue, parentGroup.Implicit(depth))
if (receiver !is InaccessibleImplicitReceiverValue) {
receiver?.let { implicitReceiverValue ->
onImplicitReceiver(implicitReceiverValue, parentGroup.Implicit(depth))
}
} }
} }
} }
@@ -76,6 +76,10 @@ class ConeWrongNumberOfTypeArgumentsError(val desiredCount: Int, val type: FirRe
override val reason: String get() = "Wrong number of type arguments" override val reason: String get() = "Wrong number of type arguments"
} }
class ConeInstanceAccessBeforeSuperCall(val target: String) : ConeDiagnostic() {
override val reason: String get() = "Cannot access ''${target}'' before superclass constructor has been called"
}
private fun describeSymbol(symbol: AbstractFirBasedSymbol<*>): String { private fun describeSymbol(symbol: AbstractFirBasedSymbol<*>): String {
return when (symbol) { return when (symbol) {
is FirClassLikeSymbol<*> -> symbol.classId.asString() is FirClassLikeSymbol<*> -> symbol.classId.asString()
@@ -88,6 +88,13 @@ class FirCallCompletionResultsWriterTransformer(
} }
} }
} else { } else {
// this branch is for cases when we have
// some invalid qualified access expression itself.
// e.g. `T::toString` where T is a generic type.
// in these cases we should report an error on
// the calleeReference.source which is not a fake source.
// uncommenting `?.fakeElement...` here removes reports
// of OTHER_ERROR from tests.
buildErrorTypeRef { buildErrorTypeRef {
source = calleeReference.source //?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef) source = calleeReference.source //?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)
diagnostic = ConeSimpleDiagnostic("Callee reference to candidate without return type: ${declaration.render()}") diagnostic = ConeSimpleDiagnostic("Callee reference to candidate without return type: ${declaration.render()}")
@@ -5,9 +5,7 @@
package org.jetbrains.kotlin.fir.resolve.transformers package org.jetbrains.kotlin.fir.resolve.transformers
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.PrivateForInline
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.diagnostics.ConeUnexpectedTypeArgumentsError import org.jetbrains.kotlin.fir.diagnostics.ConeUnexpectedTypeArgumentsError
import org.jetbrains.kotlin.fir.resolve.typeResolver import org.jetbrains.kotlin.fir.resolve.typeResolver
@@ -69,9 +67,20 @@ class FirSpecificTypeResolverTransformer(
} }
} else { } else {
buildErrorTypeRef { buildErrorTypeRef {
source = resolvedType.diagnostic.safeAs<ConeUnexpectedTypeArgumentsError>() val typeRefSourceKind = typeRef.source?.kind
?.source.safeAs() val diagnosticSource = resolvedType.diagnostic.safeAs<ConeUnexpectedTypeArgumentsError>()
?: typeRef.source ?.source.safeAs<FirSourceElement>()
source = if (diagnosticSource != null) {
if (typeRefSourceKind is FirFakeSourceElementKind) {
diagnosticSource.fakeElement(typeRefSourceKind)
} else {
diagnosticSource
}
} else {
typeRef.source
}
diagnostic = resolvedType.diagnostic diagnostic = resolvedType.diagnostic
} }
}.compose() }.compose()
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
import org.jetbrains.kotlin.fir.diagnostics.ConeIntermediateDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.*
@@ -21,6 +20,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue
import org.jetbrains.kotlin.fir.resolve.calls.InaccessibleImplicitReceiverValue
import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl
import org.jetbrains.kotlin.fir.resolve.inference.FirDelegatedPropertyInferenceSession import org.jetbrains.kotlin.fir.resolve.inference.FirDelegatedPropertyInferenceSession
import org.jetbrains.kotlin.fir.resolve.inference.extractLambdaInfoFromFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.extractLambdaInfoFromFunctionalType
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) { open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) {
private var containingClass: FirRegularClass? = null private var containingClass: FirRegularClass? = null
@@ -550,10 +551,24 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
.transformReceiverTypeRef(transformer, data) .transformReceiverTypeRef(transformer, data)
.transformReturnTypeRef(transformer, data) .transformReturnTypeRef(transformer, data)
val containers = context.containers
val owningClass = containers[containers.lastIndex - 1].safeAs<FirRegularClass>()
/* /*
* Default values of constructor can't access members of constructing class * Default values of constructor can't access members of constructing class
*/ */
context.withTowerDataContext(context.getTowerDataContextForConstructorResolution()) { context.withTowerDataContext(context.getTowerDataContextForConstructorResolution()) {
if (owningClass != null && !constructor.isPrimary) {
context.addReceiver(
null,
InaccessibleImplicitReceiverValue(
owningClass.symbol,
owningClass.defaultType(),
session,
scopeSession
)
)
}
withNewLocalScope { withNewLocalScope {
constructor.transformValueParameters(transformer, data) constructor.transformValueParameters(transformer, data)
} }
@@ -75,8 +75,24 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
implicitReceiver?.boundSymbol?.let { implicitReceiver?.boundSymbol?.let {
callee.replaceBoundSymbol(it) callee.replaceBoundSymbol(it)
} }
qualifiedAccessExpression.resultType = buildResolvedTypeRef { val implicitType = implicitReceiver?.type
type = implicitReceiver?.type ?: ConeKotlinErrorType(ConeSimpleDiagnostic("Unresolved this@$labelName", DiagnosticKind.UnresolvedLabel)) qualifiedAccessExpression.resultType = when {
implicitReceiver is InaccessibleImplicitReceiverValue -> buildErrorTypeRef {
source = qualifiedAccessExpression.source
diagnostic = ConeInstanceAccessBeforeSuperCall("<this>")
}
implicitType != null -> buildResolvedTypeRef {
source = callee.source
type = implicitType
}
labelName != null -> buildErrorTypeRef {
source = qualifiedAccessExpression.source
diagnostic = ConeSimpleDiagnostic("Unresolved this@$labelName", DiagnosticKind.UnresolvedLabel)
}
else -> buildErrorTypeRef {
source = qualifiedAccessExpression.source
diagnostic = ConeSimpleDiagnostic("'this' is not defined in this context", DiagnosticKind.NoThis)
}
} }
qualifiedAccessExpression qualifiedAccessExpression
} }
@@ -312,8 +328,17 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
block.resultType = if (resultExpression == null) { block.resultType = if (resultExpression == null) {
block.resultType.resolvedTypeFromPrototype(session.builtinTypes.unitType.type) block.resultType.resolvedTypeFromPrototype(session.builtinTypes.unitType.type)
} else { } else {
(resultExpression.resultType as? FirResolvedTypeRef) ?: buildErrorTypeRef { val theType = resultExpression.resultType
diagnostic = ConeSimpleDiagnostic("No type for block", DiagnosticKind.InferenceError) if (theType is FirResolvedTypeRef) {
buildResolvedTypeRef {
source = theType.source?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)
type = theType.type
annotations += theType.annotations
}
} else {
buildErrorTypeRef {
diagnostic = ConeSimpleDiagnostic("No type for block", DiagnosticKind.InferenceError)
}
} }
} }
@@ -489,7 +514,11 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
resolved.resultType = session.builtinTypes.booleanType resolved.resultType = session.builtinTypes.booleanType
} }
FirOperation.AS -> { FirOperation.AS -> {
resolved.resultType = conversionTypeRef resolved.resultType = buildResolvedTypeRef {
source = conversionTypeRef.source?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)
type = conversionTypeRef.coneType
annotations += conversionTypeRef.annotations
}
} }
FirOperation.SAFE_AS -> { FirOperation.SAFE_AS -> {
resolved.resultType = resolved.resultType =
@@ -763,9 +792,10 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
when (delegatedConstructorCall.calleeReference) { when (delegatedConstructorCall.calleeReference) {
is FirResolvedNamedReference, is FirErrorNamedReference -> return delegatedConstructorCall.compose() is FirResolvedNamedReference, is FirErrorNamedReference -> return delegatedConstructorCall.compose()
} }
val containers = components.context.containers
val containingClass = containers[containers.lastIndex - 1] as FirClass<*>
val containingConstructor = containers.last() as FirConstructor
if (delegatedConstructorCall.isSuper && delegatedConstructorCall.constructedTypeRef is FirImplicitTypeRef) { if (delegatedConstructorCall.isSuper && delegatedConstructorCall.constructedTypeRef is FirImplicitTypeRef) {
val containers = components.context.containers
val containingClass = containers[containers.lastIndex - 1] as FirClass<*>
val superClass = containingClass.superTypeRefs.firstOrNull { val superClass = containingClass.superTypeRefs.firstOrNull {
if (it !is FirResolvedTypeRef) return@firstOrNull false if (it !is FirResolvedTypeRef) return@firstOrNull false
val declaration = extractSuperTypeDeclaration(it) ?: return@firstOrNull false val declaration = extractSuperTypeDeclaration(it) ?: return@firstOrNull false
@@ -789,7 +819,31 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
context.getPrimaryConstructorParametersScope()?.let(context::addLocalScope) context.getPrimaryConstructorParametersScope()?.let(context::addLocalScope)
} }
delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent) // it's just a constructor parameters scope created in
// `FirDeclarationResolveTransformer::doTransformConstructor()`
val parametersScope = context.towerDataContext.localScopes.lastOrNull()
// because there's a `context.saveContextForAnonymousFunction(anonymousFunction)`
// call inside of the FirDeclarationResolveTransformer and accessing `this`
// inside a lambda which is a value parameter of a constructor delegate
// is prohibited
context.withTowerDataContext(context.getTowerDataContextForConstructorResolution()) {
parametersScope?.let {
addLocalScope(it)
}
if (containingClass is FirRegularClass && !containingConstructor.isPrimary) {
context.addReceiver(
null,
InaccessibleImplicitReceiverValue(
containingClass.symbol,
containingClass.defaultType(),
session,
scopeSession
)
)
}
delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent)
}
} }
val reference = delegatedConstructorCall.calleeReference val reference = delegatedConstructorCall.calleeReference
val constructorType: ConeClassLikeType = when (reference) { val constructorType: ConeClassLikeType = when (reference) {
@@ -814,6 +868,8 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
} }
} }
// it seems that we may leave this code as is
// without adding `context.withTowerDataContext(context.getTowerDataContextForConstructorResolution())`
val completionResult = callCompleter.completeCall(resolvedCall, noExpectedType) val completionResult = callCompleter.completeCall(resolvedCall, noExpectedType)
result = completionResult.result result = completionResult.result
callCompleted = completionResult.callCompleted callCompleted = completionResult.callCompleted
@@ -16,6 +16,7 @@ enum class DiagnosticKind {
ReturnNotAllowed, ReturnNotAllowed,
UnresolvedLabel, UnresolvedLabel,
NoThis,
IllegalConstExpression, IllegalConstExpression,
IllegalUnderscore, IllegalUnderscore,
DeserializationError, DeserializationError,
@@ -0,0 +1,4 @@
$TESTDATA_DIR$/instanceAccessBeforeSuperCall.kt
-Xuse-fir
-d
$TEMP_DIR$
@@ -0,0 +1,21 @@
class A {
constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {}
fun getSomeInt() = 10
var keker = "test"
}
class B(other: B = this)
class C() {
constructor(x: Int) : this({
val a = 10
this
}) {}
}
class D {
var a = 20
constructor() {
this.a = 10
}
}
@@ -0,0 +1,31 @@
warning: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:-SoundSmartCastsAfterTry
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:26: error: cannot access 'getSomeInt' before superclass constructor has been called
constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {}
^
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:51: error: cannot access '<this>' before superclass constructor has been called
constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {}
^
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: cannot access 'keker' before superclass constructor has been called
constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {}
^
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: variable 'keker' must be initialized
constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {}
^
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:7:20: error: 'this' is not defined in this context
class B(other: B = this)
^
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:10:32: error: type mismatch: inferred type is () -> C but Int was expected
constructor(x: Int) : this({
^
compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:12:9: error: cannot access '<this>' before superclass constructor has been called
this
^
COMPILATION_ERROR
+2 -2
View File
@@ -10,14 +10,14 @@ enum class Color {
class MyColor(val x: <!UNRESOLVED_REFERENCE!>Color.RED<!>, y: <!UNRESOLVED_REFERENCE!>Color.RED<!>) : <!UNRESOLVED_REFERENCE!>Color.RED<!> { class MyColor(val x: <!UNRESOLVED_REFERENCE!>Color.RED<!>, y: <!UNRESOLVED_REFERENCE!>Color.RED<!>) : <!UNRESOLVED_REFERENCE!>Color.RED<!> {
var z: <!UNRESOLVED_REFERENCE!>Color.RED<!> = Color.RED var z: <!UNRESOLVED_REFERENCE!>Color.RED<!> = Color.RED
set(arg: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Color.RED<!>) { z = arg } set(arg: <!UNRESOLVED_REFERENCE!>Color.RED<!>) { z = arg }
fun foo(arg: <!UNRESOLVED_REFERENCE!>Color.RED<!>): <!UNRESOLVED_REFERENCE!>Color.RED<!> = arg fun foo(arg: <!UNRESOLVED_REFERENCE!>Color.RED<!>): <!UNRESOLVED_REFERENCE!>Color.RED<!> = arg
fun bar(): <!UNRESOLVED_REFERENCE!>Color.RED<!> { fun bar(): <!UNRESOLVED_REFERENCE!>Color.RED<!> {
class Local : <!UNRESOLVED_REFERENCE!>Color.RED<!> class Local : <!UNRESOLVED_REFERENCE!>Color.RED<!>
fun local(arg: <!UNRESOLVED_REFERENCE!>Color.RED<!>): <!UNRESOLVED_REFERENCE!>Color.RED<!> = arg fun local(arg: <!UNRESOLVED_REFERENCE!>Color.RED<!>): <!UNRESOLVED_REFERENCE!>Color.RED<!> = arg
val temp: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Color.RED<!> = Color.RED val temp: <!UNRESOLVED_REFERENCE!>Color.RED<!> = Color.RED
temp as? <!UNRESOLVED_REFERENCE!>Color.RED<!> temp as? <!UNRESOLVED_REFERENCE!>Color.RED<!>
if (temp is <!UNRESOLVED_REFERENCE!>Color.RED<!>) { if (temp is <!UNRESOLVED_REFERENCE!>Color.RED<!>) {
return temp as <!UNRESOLVED_REFERENCE!>Color.RED<!> return temp as <!UNRESOLVED_REFERENCE!>Color.RED<!>
@@ -1,3 +0,0 @@
open class A(val x: Any)
class B : A(this::class)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
open class A(val x: Any) open class A(val x: Any)
class B : A(<!NO_THIS!>this<!>::class) class B : A(<!NO_THIS!>this<!>::class)
@@ -3,7 +3,7 @@
interface B<T> interface B<T>
interface G<T>: B<T> interface G<T>: B<T>
fun f(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>B<Foo><!>): Any { fun f(p: <!UNRESOLVED_REFERENCE!>B<Foo><!>): Any {
val v = p as G val v = p as G
return checkSubtype<G<*>>(v) return checkSubtype<G<*>>(v)
} }
@@ -2,7 +2,7 @@
class G<T> class G<T>
fun foo(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>P<!>) { fun foo(p: <!UNRESOLVED_REFERENCE!>P<!>) {
val v = p as G? val v = p as G?
checkSubtype<G<*>>(v!!) checkSubtype<G<*>>(v!!)
} }
@@ -15,12 +15,12 @@ fun case_3() {
} }
val x = object<T, K: Comparable<K>> { val x = object<T, K: Comparable<K>> {
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!> // OK fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!> // OK
} }
fun case_4() { fun case_4() {
val x = object<T> { val x = object<T> {
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!> fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!>
} }
val y = x.test() // type y is T val y = x.test() // type y is T
@@ -15,12 +15,12 @@ fun case_3() {
} }
val x = object<T, K: Comparable<K>> { val x = object<T, K: Comparable<K>> {
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!> // OK fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!> // OK
} }
fun case_4() { fun case_4() {
val x = object<T> { val x = object<T> {
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!> fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!>
} }
val y = x.test() // type y is T val y = x.test() // type y is T
@@ -21,5 +21,5 @@ annotation class Bar(
annotation class Baz( annotation class Baz(
val a: IntArray = [null], val a: IntArray = [null],
val b: IntArray = [1, null, 2], val b: IntArray = [1, null, 2],
val c: IntArray = [this] val c: IntArray = [<!NO_THIS!>this<!>]
) )
@@ -2,7 +2,7 @@
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
val Int.a by Delegate(this) val Int.a by Delegate(<!NO_THIS!>this<!>)
class A { class A {
val Int.a by <!INAPPLICABLE_CANDIDATE!>Delegate<!>(this) val Int.a by <!INAPPLICABLE_CANDIDATE!>Delegate<!>(this)
@@ -59,7 +59,7 @@ class MessageManager11<A> : <!UNRESOLVED_REFERENCE!>Message5<Message5<A>><!>() {
fun <T : <!UNRESOLVED_REFERENCE!>Message5<A><!>> execute() {} fun <T : <!UNRESOLVED_REFERENCE!>Message5<A><!>> execute() {}
} }
data class MessageManager12(val x: Int) : <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Message5<Message2><!>() { data class MessageManager12(val x: Int) : <!UNRESOLVED_REFERENCE!>Message5<Message2><!>() {
fun <T : Message2> execute() {} fun <T : Message2> execute() {}
} }
@@ -19,7 +19,7 @@ fun test1() {
} }
} }
fun test2(l: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>List<AA><!>) { fun test2(l: <!UNRESOLVED_REFERENCE!>List<AA><!>) {
l.<!UNRESOLVED_REFERENCE!>map<!> { l.<!UNRESOLVED_REFERENCE!>map<!> {
<!UNRESOLVED_REFERENCE!>it<!>!! <!UNRESOLVED_REFERENCE!>it<!>!!
} }
@@ -3,6 +3,6 @@
fun <T> id(x: T) = x fun <T> id(x: T) = x
fun <T> select(vararg x: T) = x[0] fun <T> select(vararg x: T) = x[0]
val x1 = select(id { this }, fun Int.() = this) val x1 = select(id { <!NO_THIS!>this<!> }, fun Int.() = this)
val x2 = select(id { this + <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>inv<!>() }, fun Int.(x: Int) = this) val x2 = select(id { <!NO_THIS!>this<!> + <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>inv<!>() }, fun Int.(x: Int) = this)
val x3 = select(id { this.<!UNRESOLVED_REFERENCE!>length<!> + <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>inv<!>() }, fun String.(x: Int) = length) val x3 = select(id { <!NO_THIS!>this<!>.<!UNRESOLVED_REFERENCE!>length<!> + <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>inv<!>() }, fun String.(x: Int) = length)
@@ -19,7 +19,7 @@ public class Foo {
// FILE: test.kt // FILE: test.kt
fun test(e: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>ErrorType<!>) { fun test(e: <!UNRESOLVED_REFERENCE!>ErrorType<!>) {
Foo.foo { Foo.foo {
Sam.Result.<!INAPPLICABLE_CANDIDATE!>create<!>(e) Sam.Result.<!INAPPLICABLE_CANDIDATE!>create<!>(e)
} }
@@ -3,14 +3,14 @@
fun <T> select(vararg x: T) = x[0] fun <T> select(vararg x: T) = x[0]
fun main() { fun main() {
val x1: String.() -> String = if (true) {{ this }} else {{ this }} val x1: String.() -> String = if (true) {{ <!NO_THIS!>this<!> }} else {{ <!NO_THIS!>this<!> }}
val x2: String.() -> String = if (true) {{ -> this }} else {{ -> this }} val x2: String.() -> String = if (true) {{ -> <!NO_THIS!>this<!> }} else {{ -> <!NO_THIS!>this<!> }}
val x3: () -> String = if (true) {{ -> "this" }} else {{ -> "this" }} val x3: () -> String = if (true) {{ -> "this" }} else {{ -> "this" }}
val x4: String.() -> String = if (true) {{ str: String -> "this" }} else {{ str: String -> "this" }} val x4: String.() -> String = if (true) {{ str: String -> "this" }} else {{ str: String -> "this" }}
val x41: String.(String) -> String = if (true) {{ str: String, str2: String -> "this" }} else {{ str: String, str2: String -> "this" }} val x41: String.(String) -> String = if (true) {{ str: String, str2: String -> "this" }} else {{ str: String, str2: String -> "this" }}
val x42: String.(String) -> String = if (true) {{ str, str2 -> "this" }} else {{ str, str2 -> "this" }} val x42: String.(String) -> String = if (true) {{ str, str2 -> "this" }} else {{ str, str2 -> "this" }}
val x5: String.() -> String = if (true) {{ str -> "this" }} else {{ str -> "this" }} val x5: String.() -> String = if (true) {{ str -> "this" }} else {{ str -> "this" }}
val x6: String.() -> String = if (true) {{ str -> "this" }} else {{ "this" }} val x6: String.() -> String = if (true) {{ str -> "this" }} else {{ "this" }}
val x7: String.() -> String = select({ -> this }, { -> this }) val x7: String.() -> String = select({ -> <!NO_THIS!>this<!> }, { -> <!NO_THIS!>this<!> })
val x8: String.() -> String = select({ this }, { this }) val x8: String.() -> String = select({ <!NO_THIS!>this<!> }, { <!NO_THIS!>this<!> })
} }
@@ -6,11 +6,11 @@ interface Trait {
class Outer : Trait { class Outer : Trait {
class Nested { class Nested {
val t = this@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val t = <!UNRESOLVED_LABEL!>this@Outer<!>.<!UNRESOLVED_REFERENCE!>bar<!>()
val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>()
inner class NestedInner { inner class NestedInner {
val t = this@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val t = <!UNRESOLVED_LABEL!>this@Outer<!>.<!UNRESOLVED_REFERENCE!>bar<!>()
val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>()
} }
} }
@@ -7,8 +7,8 @@ class Outer {
class Nested { class Nested {
fun f() = <!UNRESOLVED_REFERENCE!>function<!>() fun f() = <!UNRESOLVED_REFERENCE!>function<!>()
fun g() = <!UNRESOLVED_REFERENCE!>property<!> fun g() = <!UNRESOLVED_REFERENCE!>property<!>
fun h() = this@Outer.<!UNRESOLVED_REFERENCE!>function<!>() fun h() = <!UNRESOLVED_LABEL!>this@Outer<!>.<!UNRESOLVED_REFERENCE!>function<!>()
fun i() = this@Outer.<!UNRESOLVED_REFERENCE!>property<!> fun i() = <!UNRESOLVED_LABEL!>this@Outer<!>.<!UNRESOLVED_REFERENCE!>property<!>
} }
inner class Inner { inner class Inner {
@@ -1,17 +1,17 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE // !DIAGNOSTICS: -UNUSED_VARIABLE
val funLit = lambda@ fun String.() { val funLit = lambda@ fun String.() {
val d1 = this@lambda val d1 = <!UNRESOLVED_LABEL!>this@lambda<!>
} }
fun test() { fun test() {
val funLit = lambda@ fun String.(): String { val funLit = lambda@ fun String.(): String {
return this@lambda return <!UNRESOLVED_LABEL!>this@lambda<!>
} }
} }
fun lambda() { fun lambda() {
val funLit = lambda@ fun String.(): String { val funLit = lambda@ fun String.(): String {
return this@lambda return <!UNRESOLVED_LABEL!>this@lambda<!>
} }
} }
@@ -4,10 +4,10 @@ interface Iterator<out T> {
fun <R> map(transform: (element: T) -> R) : Iterator<R> = fun <R> map(transform: (element: T) -> R) : Iterator<R> =
object : Iterator<R> { object : Iterator<R> {
override fun next() : R = transform(this@map.<!UNRESOLVED_REFERENCE!>next<!>()) override fun next() : R = transform(<!UNRESOLVED_LABEL!>this@map<!>.<!UNRESOLVED_REFERENCE!>next<!>())
override val hasNext : Boolean override val hasNext : Boolean
// There's no 'this' associated with the map() function, only this of the Iterator class // There's no 'this' associated with the map() function, only this of the Iterator class
get() = this@map.<!UNRESOLVED_REFERENCE!>hasNext<!> get() = <!UNRESOLVED_LABEL!>this@map<!>.<!UNRESOLVED_REFERENCE!>hasNext<!>
} }
} }
@@ -39,8 +39,8 @@ class W4(val f: L2) {
fun test1() { // to extension lambda 0 fun test1() { // to extension lambda 0
val w10 = W1 { this } // oi+ ni+ val w10 = W1 { this } // oi+ ni+
val i10: E0 = id { this } // o1- ni+ val i10: E0 = id { <!NO_THIS!>this<!> } // o1- ni+
val j10 = id<E0> { this } // oi+ ni+ val j10 = id<E0> { <!NO_THIS!>this<!> } // oi+ ni+
val f10 = W1(fun Int.(): Int = this) // oi+ ni+ val f10 = W1(fun Int.(): Int = this) // oi+ ni+
val g10: E0 = id(fun Int.(): Int = this) // oi+ ni+ val g10: E0 = id(fun Int.(): Int = this) // oi+ ni+
@@ -60,28 +60,28 @@ fun test1() { // to extension lambda 0
fun test2() { // to extension lambda 1 fun test2() { // to extension lambda 1
val w20 = W2 { this + it.length } // oi+ ni+ val w20 = W2 { this + it.length } // oi+ ni+
val i20: E1 = id { this + <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>length<!> } // oi- ni+ val i20: E1 = id { <!NO_THIS!>this<!> + <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>length<!> } // oi- ni+
val w21 = W2 { this } // oi+ ni+ val w21 = W2 { this } // oi+ ni+
val i21: E1 = id { this } // oi- ni+ val i21: E1 = id { <!NO_THIS!>this<!> } // oi- ni+
val f21 = W2(fun Int.(String): Int = this) // oi+ ni+ val f21 = W2(fun Int.(String): Int = this) // oi+ ni+
val g21: E1 = id(fun Int.(String): Int = this) // oi+ ni+ val g21: E1 = id(fun Int.(String): Int = this) // oi+ ni+
val w22 = W2 { s -> this + s.length } // oi+ ni+ val w22 = W2 { s -> this + s.length } // oi+ ni+
val i22: E1 = id { s -> this + s.<!UNRESOLVED_REFERENCE!>length<!> } // oi+ ni+ val i22: E1 = id { s -> <!NO_THIS!>this<!> + s.<!UNRESOLVED_REFERENCE!>length<!> } // oi+ ni+
val w23 = W2 { s -> s.length } // oi+ ni+ val w23 = W2 { s -> s.length } // oi+ ni+
val i23: E1 = id { s -> s.<!UNRESOLVED_REFERENCE!>length<!> } // oi+ ni+ val i23: E1 = id { s -> s.<!UNRESOLVED_REFERENCE!>length<!> } // oi+ ni+
val w24 = W2 { s: String -> this + s.length } // oi+ ni+ val w24 = W2 { s: String -> this + s.length } // oi+ ni+
val i24: E1 = id { s: String -> this + s.length } //oi- ni+ val i24: E1 = id { s: String -> <!NO_THIS!>this<!> + s.length } //oi- ni+
val w25 = W2 { s: String -> s.length } // oi+ ni+ val w25 = W2 { s: String -> s.length } // oi+ ni+
val i25: E1 = id { s: String -> s.length } // oi- ni+ val i25: E1 = id { s: String -> s.length } // oi- ni+
val w26 = W2(id { s: String -> this + s.length }) // oi- ni+ val w26 = W2(id { s: String -> <!NO_THIS!>this<!> + s.length }) // oi- ni+
val w26a = W2(id { s -> this + s.<!UNRESOLVED_REFERENCE!>length<!> }) // oi+ ni+ val w26a = W2(id { s -> <!NO_THIS!>this<!> + s.<!UNRESOLVED_REFERENCE!>length<!> }) // oi+ ni+
val i26: E1 = id { s: String -> this + s.length } // oi- ni+ val i26: E1 = id { s: String -> <!NO_THIS!>this<!> + s.length } // oi- ni+
val i26a: E1 = id { s -> this + s.<!UNRESOLVED_REFERENCE!>length<!> } // oi+ ni+ val i26a: E1 = id { s -> <!NO_THIS!>this<!> + s.<!UNRESOLVED_REFERENCE!>length<!> } // oi+ ni+
val e = E.VALUE val e = E.VALUE
val w27 = <!INAPPLICABLE_CANDIDATE!>W2<!>(when (e) { E.VALUE -> { s: String -> this + s.length } }) // oi- ni+ val w27 = <!INAPPLICABLE_CANDIDATE!>W2<!>(when (e) { E.VALUE -> { s: String -> <!NO_THIS!>this<!> + s.length } }) // oi- ni+
val w27a = <!INAPPLICABLE_CANDIDATE!>W2<!>(when (e) { E.VALUE -> { s -> this + s.<!UNRESOLVED_REFERENCE!>length<!> } }) // oi+ ni+ val w27a = <!INAPPLICABLE_CANDIDATE!>W2<!>(when (e) { E.VALUE -> { s -> <!NO_THIS!>this<!> + s.<!UNRESOLVED_REFERENCE!>length<!> } }) // oi+ ni+
val i27: E1 = when (e) { E.VALUE -> { s: String -> this + s.length } } // oi+ ni+ val i27: E1 = when (e) { E.VALUE -> { s: String -> <!NO_THIS!>this<!> + s.length } } // oi+ ni+
val i27a: E1 = when (e) { E.VALUE -> { s -> this + s.<!UNRESOLVED_REFERENCE!>length<!> } } // oi+ ni+ val i27a: E1 = when (e) { E.VALUE -> { s -> <!NO_THIS!>this<!> + s.<!UNRESOLVED_REFERENCE!>length<!> } } // oi+ ni+
val w28 = <!INAPPLICABLE_CANDIDATE!>W2<!> { i: Int, s -> i <!AMBIGUITY!>+<!> s.<!UNRESOLVED_REFERENCE!>length<!> } // oi- ni- val w28 = <!INAPPLICABLE_CANDIDATE!>W2<!> { i: Int, s -> i <!AMBIGUITY!>+<!> s.<!UNRESOLVED_REFERENCE!>length<!> } // oi- ni-
val i28: E1 = id { i: Int, s -> i + s.length } // oi- ni- val i28: E1 = id { i: Int, s -> i + s.length } // oi- ni-
@@ -1,10 +0,0 @@
interface A { fun f() }
open class P(val z: B)
class B : A {
override fun f() {}
class C : A by this {}
class D(val x : B = this)
class E : P(this)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface A { fun f() } interface A { fun f() }
open class P(val z: B) open class P(val z: B)
@@ -6,6 +6,6 @@ fun foo(i: Int, f: Int.()->Int) = i.f()
fun test1() { fun test1() {
<!AMBIGUITY!>foo<!>(1) { -> <!AMBIGUITY!>foo<!>(1) { ->
this <!NO_THIS!>this<!>
} }
} }
@@ -37,8 +37,8 @@ class A(
Companion.CONST, Companion.CONST,
Nested.CONST, Nested.CONST,
Interface.CONST, Interface.CONST,
a, <!UNRESOLVED_REFERENCE!>a<!>,
b() <!UNRESOLVED_REFERENCE!>b<!>()
) )
class Nested { class Nested {
@@ -22,8 +22,8 @@ class A : S {
Companion.CONST, Companion.CONST,
Nested.CONST, Nested.CONST,
Interface.CONST, Interface.CONST,
a, <!UNRESOLVED_REFERENCE!>a<!>,
b() <!UNRESOLVED_REFERENCE!>b<!>()
) )
class Nested { class Nested {
@@ -6,7 +6,7 @@ val <T> List<T>.length = <!UNRESOLVED_REFERENCE!>size<!>
val <T> List<T>.length1 : Int get() = size val <T> List<T>.length1 : Int get() = size
val String.bd = this + "!" val String.bd = <!NO_THIS!>this<!> + "!"
val String.bd1 : String get() = this + "!" val String.bd1 : String get() = this + "!"
@@ -31,7 +31,7 @@ open class BodyTag(name : String) : TagWithText(name) {
class Body() : BodyTag(<!UNRESOLVED_REFERENCE!>name<!>) { // Must be an error! class Body() : BodyTag(<!UNRESOLVED_REFERENCE!>name<!>) { // Must be an error!
} }
class Body1() : BodyTag(this.<!UNRESOLVED_REFERENCE!>name<!>) { // Must be an error! class Body1() : BodyTag(<!NO_THIS!>this<!>.<!UNRESOLVED_REFERENCE!>name<!>) { // Must be an error!
} }
//more tests //more tests
@@ -6,7 +6,7 @@ open class Base<T>(p: Any?) {
class D: Base<Int>("") { class D: Base<Int>("") {
inner class B : Base<String> { inner class B : Base<String> {
constructor() : super(foo1("")) constructor() : super(<!INAPPLICABLE_CANDIDATE!>foo1<!>(""))
constructor(x: Int) : super(foo1(1)) constructor(x: Int) : super(foo1(1))
} }
} }
@@ -7,7 +7,7 @@ open class Base<T>(p: Any?) {
class D: Base<Int>(1) { class D: Base<Int>(1) {
inner class B : Base<Int> { inner class B : Base<Int> {
constructor() : super(foo1(1)) constructor() : super(foo1(1))
constructor(x: Int) : super(this@B.foo1(1)) constructor(x: Int) : super(<!UNRESOLVED_LABEL!>this@B<!>.<!UNRESOLVED_REFERENCE!>foo1<!>(1))
constructor(x: Int, y: Int) : super(this@D.foo1(1)) constructor(x: Int, y: Int) : super(this@D.foo1(1))
} }
} }
@@ -7,6 +7,6 @@ fun Base.foo() {
class B : Base { class B : Base {
constructor() : super(foo1()) constructor() : super(foo1())
constructor(x: Int) : super(this@foo.foo1()) constructor(x: Int) : super(this@foo.foo1())
constructor(x: Int, y: Int) : super(this@B.foo1()) constructor(x: Int, y: Int) : super(<!UNRESOLVED_LABEL!>this@B<!>.<!UNRESOLVED_REFERENCE!>foo1<!>())
} }
} }
@@ -5,9 +5,9 @@ open class Base<T>(p: Any?) {
fun Base<Int>.foo() { fun Base<Int>.foo() {
class B : Base<String> { class B : Base<String> {
constructor() : super(foo1("")) constructor() : super(<!INAPPLICABLE_CANDIDATE!>foo1<!>(""))
constructor(x: Int) : super(foo1(1)) constructor(x: Int) : super(foo1(1))
constructor(x: Int, y: Int) : super(this@foo.foo1(12)) constructor(x: Int, y: Int) : super(this@foo.foo1(12))
constructor(x: Int, y: Int, z: Int) : super(this@B.foo1("")) constructor(x: Int, y: Int, z: Int) : super(<!UNRESOLVED_LABEL!>this@B<!>.<!UNRESOLVED_REFERENCE!>foo1<!>(""))
} }
} }
@@ -6,6 +6,6 @@ class Outer {
} }
constructor(x: Int) constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x + Inner().prop <!AMBIGUITY!>+<!> this.<!UNRESOLVED_REFERENCE!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!>) : constructor(x: Int, y: Int, z: Int = x + Inner().prop <!AMBIGUITY!>+<!> <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!>) :
this(x + Inner().prop + this.Inner().prop) this(x + Inner().prop <!AMBIGUITY!>+<!> <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!>)
} }
@@ -7,9 +7,9 @@ class A {
constructor(x: () -> Int) constructor(x: () -> Int)
constructor() : this( constructor() : this(
{ {
foo() + <!UNRESOLVED_REFERENCE!>foo<!>() +
this.foo() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>() +
this@A.foo() + <!UNRESOLVED_LABEL!>this@A<!>.<!UNRESOLVED_REFERENCE!>foo<!>() +
foobar() <!UNRESOLVED_REFERENCE!>foobar<!>()
}) })
} }
@@ -2,6 +2,6 @@
class A { class A {
fun foo() = 1 fun foo() = 1
constructor(x: Int) constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + this.<!UNRESOLVED_REFERENCE!>foo<!>()) : constructor(x: Int, y: Int, z: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>()) :
this(x + foo() + this.foo()) <!INAPPLICABLE_CANDIDATE!>this<!>(x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>())
} }
@@ -6,7 +6,7 @@ class A {
fun foo() = 1 fun foo() = 1
constructor(x: Any?) constructor(x: Any?)
constructor() : this(object { constructor() : this(object {
fun bar() = foo() + this@A.foo() + fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + <!UNRESOLVED_LABEL!>this@A<!>.<!UNRESOLVED_REFERENCE!>foo<!>() +
foobar() + super@A.hashCode() <!INAPPLICABLE_CANDIDATE!>foobar<!>() + super@A.<!UNRESOLVED_REFERENCE!>hashCode<!>()
}) })
} }
@@ -5,7 +5,7 @@ fun A.foobar() = 3
class A { class A {
fun foo() = 1 fun foo() = 1
constructor( x: Any = object { constructor( x: Any = object {
fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + this@A.<!UNRESOLVED_REFERENCE!>foo<!>() + fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + <!UNRESOLVED_LABEL!>this@A<!>.<!UNRESOLVED_REFERENCE!>foo<!>() +
<!INAPPLICABLE_CANDIDATE!>foobar<!>() <!INAPPLICABLE_CANDIDATE!>foobar<!>()
}) })
} }
@@ -4,8 +4,8 @@ class D : C {
constructor() : super( constructor() : super(
{ {
val s = "" val s = ""
s() <!UNRESOLVED_REFERENCE!>s<!>()
""() <!UNRESOLVED_REFERENCE!>""()<!>
42 42
}()) }())
@@ -3,6 +3,6 @@ fun foo(x: A) = 1
class A { class A {
constructor(x: Int) constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x + foo(this) + foo(this@A)) : constructor(x: Int, y: Int, z: Int = x + foo(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) + foo(<!UNRESOLVED_LABEL!>this@A<!>)) :
this(x + foo(this) + foo(this@A)) this(x + foo(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) + foo(<!UNRESOLVED_LABEL!>this@A<!>))
} }
@@ -2,6 +2,6 @@
class A { class A {
val prop = 1 val prop = 1
constructor(x: Int) constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + this.<!UNRESOLVED_REFERENCE!>prop<!>) : constructor(x: Int, y: Int, z: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>prop<!>) :
this(x + prop + this.prop) <!INAPPLICABLE_CANDIDATE!>this<!>(x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>prop<!>)
} }
@@ -2,6 +2,6 @@
open class B(x: Int) open class B(x: Int)
class A : B { class A : B {
val prop = 1 val prop = 1
constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + this.<!UNRESOLVED_REFERENCE!>prop<!>) : constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>prop<!>) :
super(x + prop + this.prop) <!INAPPLICABLE_CANDIDATE!>super<!>(x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>prop<!>)
} }
@@ -3,6 +3,6 @@ open class B(x: Int) {
fun foo() = 1 fun foo() = 1
} }
class A : B { class A : B {
constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + this.<!UNRESOLVED_REFERENCE!>foo<!>() + super.<!UNRESOLVED_REFERENCE!>foo<!>()) : constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>() + super.<!UNRESOLVED_REFERENCE!>foo<!>()) :
super(x + foo() + this.foo() + super.foo()) <!INAPPLICABLE_CANDIDATE!>super<!>(x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>() + super.<!UNRESOLVED_REFERENCE!>foo<!>())
} }
@@ -4,6 +4,6 @@ open class B(x: Int) {
} }
class A : B { class A : B {
override fun foo() = 2 override fun foo() = 2
constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + this.<!UNRESOLVED_REFERENCE!>foo<!>() + super.<!UNRESOLVED_REFERENCE!>foo<!>()) : constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>() + super.<!UNRESOLVED_REFERENCE!>foo<!>()) :
super(x + foo() + this.foo() + super.foo()) <!INAPPLICABLE_CANDIDATE!>super<!>(x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>foo<!>() + super.<!UNRESOLVED_REFERENCE!>foo<!>())
} }
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
open class B(val prop: Int) open class B(val prop: Int)
class A : B { class A : B {
constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + this.<!UNRESOLVED_REFERENCE!>prop<!> + super.<!UNRESOLVED_REFERENCE!>prop<!>) : constructor(x: Int, y: Int = x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>prop<!> + super.<!UNRESOLVED_REFERENCE!>prop<!>) :
super(x + prop + this.prop + super.prop) <!INAPPLICABLE_CANDIDATE!>super<!>(x <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>prop<!> + super.<!UNRESOLVED_REFERENCE!>prop<!>)
} }
@@ -5,11 +5,11 @@ val A.prop: Int get() = 2
class A { class A {
constructor(x: Int) constructor(x: Int)
constructor() : this( constructor() : <!INAPPLICABLE_CANDIDATE!>this<!>(
foobar() + <!UNRESOLVED_REFERENCE!>foobar<!>() +
this.foobar() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.foobar() +
prop + <!UNRESOLVED_REFERENCE!>prop<!> +
this.prop + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.prop +
this@A.prop <!UNRESOLVED_LABEL!>this@A<!>.prop
) )
} }
@@ -2,7 +2,7 @@
class A() { class A() {
fun foo() : Unit { fun foo() : Unit {
this@A this@A
this@a <!UNRESOLVED_LABEL!>this@a<!>
this this
} }
@@ -11,7 +11,7 @@ class A(val a:Int) {
checkSubtype<A>(this@A) checkSubtype<A>(this@A)
} }
val b: Double.() -> Unit = a@{ checkSubtype<Double>(this@a) + checkSubtype<Byte>(this@xx) } val b: Double.() -> Unit = a@{ checkSubtype<Double>(this@a) + checkSubtype<Byte>(this@xx) }
val c = a@{ -> this@a + checkSubtype<Byte>(this@xx) } val c = a@{ -> <!UNRESOLVED_LABEL!>this@a<!> + checkSubtype<Byte>(this@xx) }
return (a@{checkSubtype<Double>(this@a) + checkSubtype<Byte>(this@xx)}) return (a@{checkSubtype<Double>(this@a) + checkSubtype<Byte>(this@xx)})
} }
} }
@@ -3,6 +3,6 @@ interface Base {
} }
val String.test: Base = object: Base { val String.test: Base = object: Base {
override fun foo() { override fun foo() {
this@test <!UNRESOLVED_LABEL!>this@test<!>
} }
} }
@@ -1,4 +1,4 @@
fun foo1() : Unit { fun foo1() : Unit {
this <!NO_THIS!>this<!>
this@a <!UNRESOLVED_LABEL!>this@a<!>
} }
@@ -6,8 +6,8 @@ open class Base {
class Derived : Base() class Derived : Base()
fun test(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Derived.Nested<!>) = x fun test(x: <!UNRESOLVED_REFERENCE!>Derived.Nested<!>) = x
fun Base.testWithImplicitReceiver(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Nested<!>) { fun Base.testWithImplicitReceiver(x: <!UNRESOLVED_REFERENCE!>Nested<!>) {
val y: <!UNRESOLVED_REFERENCE!>Nested<!> = x val y: <!UNRESOLVED_REFERENCE!>Nested<!> = x
} }
@@ -11,12 +11,12 @@ class Outer<T> {
typealias InnerAlias = Inner typealias InnerAlias = Inner
typealias GenericInnerAlias<TT> = GenericInner<TT> typealias GenericInnerAlias<TT> = GenericInner<TT>
fun test1(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>NestedAlias<!>) = x fun test1(x: <!UNRESOLVED_REFERENCE!>NestedAlias<!>) = x
fun test2(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>GenericNestedAlias<Int><!>) = x fun test2(x: <!UNRESOLVED_REFERENCE!>GenericNestedAlias<Int><!>) = x
fun <T> test3(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>GenericNestedAlias<T><!>) = x fun <T> test3(x: <!UNRESOLVED_REFERENCE!>GenericNestedAlias<T><!>) = x
fun test4(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>InnerAlias<!>) = x fun test4(x: <!UNRESOLVED_REFERENCE!>InnerAlias<!>) = x
fun test5(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>GenericInnerAlias<Int><!>) = x fun test5(x: <!UNRESOLVED_REFERENCE!>GenericInnerAlias<Int><!>) = x
fun <T> test6(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>GenericInnerAlias<T><!>) = x fun <T> test6(x: <!UNRESOLVED_REFERENCE!>GenericInnerAlias<T><!>) = x
} }
fun test1(x: Outer<Int>.NestedAlias) = x fun test1(x: Outer<Int>.NestedAlias) = x
fun <T> test2(x: Outer<T>.NestedAlias) = x fun <T> test2(x: Outer<T>.NestedAlias) = x
@@ -5,12 +5,12 @@ fun <T> emptyList(): List<T> = null!!
fun <T> foo() { fun <T> foo() {
typealias LT = List<T> typealias LT = List<T>
val a: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>LT<!> = emptyList() val a: <!UNRESOLVED_REFERENCE!>LT<!> = emptyList()
fun localFun(): <!UNRESOLVED_REFERENCE!>LT<!> { fun localFun(): <!UNRESOLVED_REFERENCE!>LT<!> {
typealias LLT = List<T> typealias LLT = List<T>
val b: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>LLT<!> = a val b: <!UNRESOLVED_REFERENCE!>LLT<!> = a
return b return b
} }
@@ -4,8 +4,8 @@ class Cell<TC>(val x: TC)
fun <T> id(x: T): T { fun <T> id(x: T): T {
typealias C = Cell<T> typealias C = Cell<T>
class Local(val cell: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>C<!>) class Local(val cell: <!UNRESOLVED_REFERENCE!>C<!>)
val cx = <!UNRESOLVED_REFERENCE!>C<!>(x) val cx = <!UNRESOLVED_REFERENCE!>C<!>(x)
val c: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>C<!> = Local(cx).cell val c: <!UNRESOLVED_REFERENCE!>C<!> = Local(cx).cell
return c.<!UNRESOLVED_REFERENCE!>x<!> return c.<!UNRESOLVED_REFERENCE!>x<!>
} }
@@ -6,8 +6,8 @@ class C {
typealias P2 = Pair<Int, Int> typealias P2 = Pair<Int, Int>
fun p() = <!UNRESOLVED_REFERENCE!>P2<!>(1, 1) fun p() = <!UNRESOLVED_REFERENCE!>P2<!>(1, 1)
fun first(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x1<!> fun first(p: <!UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x1<!>
fun second(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x2<!> fun second(p: <!UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x2<!>
} }
val p1 = Pair(1, 1) val p1 = Pair(1, 1)
@@ -6,11 +6,11 @@ class C<T> {
typealias P2 = Pair<T, T> typealias P2 = Pair<T, T>
typealias PT2<T2> = Pair<T, T2> typealias PT2<T2> = Pair<T, T2>
fun first(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x1<!> fun first(p: <!UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x1<!>
fun second(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x2<!> fun second(p: <!UNRESOLVED_REFERENCE!>P2<!>) = p.<!UNRESOLVED_REFERENCE!>x2<!>
fun <T2> first2(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>PT2<T2><!>) = p.<!UNRESOLVED_REFERENCE!>x1<!> fun <T2> first2(p: <!UNRESOLVED_REFERENCE!>PT2<T2><!>) = p.<!UNRESOLVED_REFERENCE!>x1<!>
fun <T2> second2(p: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>PT2<T2><!>) = p.<!UNRESOLVED_REFERENCE!>x2<!> fun <T2> second2(p: <!UNRESOLVED_REFERENCE!>PT2<T2><!>) = p.<!UNRESOLVED_REFERENCE!>x2<!>
} }
val p1 = Pair(1, 1) val p1 = Pair(1, 1)
@@ -10,13 +10,13 @@ class Foo {
inner class Bar { inner class Bar {
fun good() { fun good() {
contract { contract {
returns() implies (this@Bar != null) returns() implies (<!UNRESOLVED_LABEL!>this@Bar<!> != null)
} }
} }
fun badOuter() { fun badOuter() {
contract { contract {
returns() implies (this@Foo != null) returns() implies (<!UNRESOLVED_LABEL!>this@Foo<!> != null)
} }
} }
@@ -34,7 +34,7 @@ class Foo {
fun A?.badWithReceiver() { fun A?.badWithReceiver() {
contract { contract {
returns() implies (this@Bar != null) returns() implies (<!UNRESOLVED_LABEL!>this@Bar<!> != null)
} }
} }
} }
@@ -3,7 +3,7 @@
interface Inv interface Inv
class Impl : Inv class Impl : Inv
class Scope<InterfaceT, ImplementationT : InterfaceT>(private val implClass: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>j.Class<ImplementationT><!>) { class Scope<InterfaceT, ImplementationT : InterfaceT>(private val implClass: <!UNRESOLVED_REFERENCE!>j.Class<ImplementationT><!>) {
fun foo(c: Collection<InterfaceT>) { fun foo(c: Collection<InterfaceT>) {
val hm = c.asSequence() val hm = c.asSequence()
.<!INAPPLICABLE_CANDIDATE!>filter<!>(<!UNRESOLVED_REFERENCE!>implClass::isInstance<!>) .<!INAPPLICABLE_CANDIDATE!>filter<!>(<!UNRESOLVED_REFERENCE!>implClass::isInstance<!>)
@@ -1,5 +1,5 @@
data class A(val x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Set<CLassNotFound><!> = setOf()) { data class A(val x: <!UNRESOLVED_REFERENCE!>Set<CLassNotFound><!> = setOf()) {
fun with(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Set<CLassNotFound>?<!> = null) { fun with(x: <!UNRESOLVED_REFERENCE!>Set<CLassNotFound>?<!> = null) {
A(x ?: this.x) A(x ?: this.x)
} }
} }
@@ -32,7 +32,7 @@ fun case_2() {
class case_4 : ClassLevel3() { class case_4 : ClassLevel3() {
fun <T : Number?>T.case_4_1(): Boolean { fun <T : Number?>T.case_4_1(): Boolean {
contract { returns(false) implies (this@case_4 !is ClassLevel1) } contract { returns(false) implies (<!UNRESOLVED_LABEL!>this@case_4<!> !is ClassLevel1) }
return this == null return this == null
} }
@@ -60,12 +60,12 @@ class case_4 : ClassLevel3() {
class case_5<T> : ClassLevel5() { class case_5<T> : ClassLevel5() {
inner class case_5_1 { inner class case_5_1 {
fun <K : Number?>K.case_5_1_1() { fun <K : Number?>K.case_5_1_1() {
contract { returns() implies (this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this@case_5_1_1 is Float) } contract { returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 && <!UNRESOLVED_LABEL!>this@case_5_1<!> != null || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 && this@case_5_1_1 is Float) }
if (!(this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this is Float)) throw Exception() if (!(this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this is Float)) throw Exception()
} }
fun case_5_1_2() { fun case_5_1_2() {
contract { returns() implies (this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null) } contract { returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5_1<!> == null) }
if (!(this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null)) throw Exception() if (!(this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null)) throw Exception()
} }
} }
@@ -179,7 +179,7 @@ fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndire
else "-1" else "-1"
// TESTCASE NUMBER: 13 // TESTCASE NUMBER: 13
fun case_13(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>otherpackage.Case13?<!>) = fun case_13(x: <!UNRESOLVED_REFERENCE!>otherpackage.Case13?<!>) =
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Can't resolve when expression")!>if ((x == null !is Boolean) !== true) { <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Can't resolve when expression")!>if ((x == null !is Boolean) !== true) {
throw Exception() throw Exception()
} else { } else {
@@ -189,7 +189,7 @@ fun case_13(x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENC
// TESTCASE NUMBER: 14 // TESTCASE NUMBER: 14
class Case14 { class Case14 {
val x: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>otherpackage.Case14?<!> val x: <!UNRESOLVED_REFERENCE!>otherpackage.Case14?<!>
init { init {
x = <!UNRESOLVED_REFERENCE!>otherpackage<!>.<!UNRESOLVED_REFERENCE!>Case14<!>() x = <!UNRESOLVED_REFERENCE!>otherpackage<!>.<!UNRESOLVED_REFERENCE!>Case14<!>()
} }
@@ -335,6 +335,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/inlineCycle_ir.args"); runTest("compiler/testData/cli/jvm/inlineCycle_ir.args");
} }
@TestMetadata("instanceAccessBeforeSuperCall.args")
public void testInstanceAccessBeforeSuperCall() throws Exception {
runTest("compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.args");
}
@TestMetadata("internalArgDisableLanguageFeature.args") @TestMetadata("internalArgDisableLanguageFeature.args")
public void testInternalArgDisableLanguageFeature() throws Exception { public void testInternalArgDisableLanguageFeature() throws Exception {
runTest("compiler/testData/cli/jvm/internalArgDisableLanguageFeature.args"); runTest("compiler/testData/cli/jvm/internalArgDisableLanguageFeature.args");