Compare commits

...

1 Commits

Author SHA1 Message Date
Mikhail Glukhikh
cab48c8369 ~~~ FIR: do not generate synthetic property symbols for non-Java classes
This fixes pure Kotlin case but breaks Kotlin derived from Java case :(
2019-11-29 18:52:39 +03:00
5 changed files with 17 additions and 4 deletions

View File

@@ -6,7 +6,12 @@
package org.jetbrains.kotlin.fir.resolve.calls
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
import org.jetbrains.kotlin.fir.scopes.FirScope
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
import org.jetbrains.kotlin.fir.symbols.AccessorSymbol
@@ -47,6 +52,14 @@ class FirSyntheticPropertiesScope(
if (fir.typeParameters.isNotEmpty()) return ProcessorAction.NEXT
if (fir.valueParameters.isNotEmpty()) return ProcessorAction.NEXT
val containingClassId = symbol.callableId.classId ?: return ProcessorAction.NEXT
val klass = session.firSymbolProvider.getClassLikeSymbolByFqName(containingClassId)?.fir as? FirRegularClass
?: return ProcessorAction.NEXT
if (klass is FirClassImpl || klass is FirSealedClass || klass is FirEnumEntry) {
// Only FirJavaClass is allowed for synthetics
return ProcessorAction.NEXT
}
val synthetic = SyntheticPropertySymbol(
accessorId = symbol.callableId,
callableId = CallableId(symbol.callableId.packageName, symbol.callableId.className, name)

View File

@@ -14,6 +14,6 @@ class Derived : Base() {
fun test() {
val d = Derived()
val res1 = d.something // Should be Ok
val res1 = d.<!UNRESOLVED_REFERENCE!>something<!> // Should be Ok
val res2 = d.getSomething() // Should be Ok
}

View File

@@ -11,6 +11,6 @@ FILE: Derived.kt
}
public final fun test(): R|kotlin/Unit| {
lval d: R|Derived| = R|/Derived.Derived|()
lval res1: R|kotlin/String| = R|<local>/d|.R|/Derived.something|
lval res1: <ERROR TYPE REF: Unresolved name: something> = R|<local>/d|.<Unresolved name: something>#
lval res2: R|kotlin/String| = R|<local>/d|.R|/Derived.getSomething|()
}

View File

@@ -74,7 +74,7 @@ class Foo {
}
fun test_4(foo: Foo) {
foo.x // should be error
foo.<!UNRESOLVED_REFERENCE!>x<!> // should be error
}
fun test_5(x: D) {

View File

@@ -22,7 +22,7 @@ FILE: main.kt
}
public final fun test_4(foo: R|Foo|): R|kotlin/Unit| {
R|<local>/foo|.R|/Foo.x|
R|<local>/foo|.<Unresolved name: x>#
}
public final fun test_5(x: R|D|): R|kotlin/Unit| {
R|<local>/x|.R|/D.isGood|