Set the right call operation node for implicit invoke

Make a call for implicit invoke safe if an outer call is safe
This commit is contained in:
Svetlana Isakova
2014-10-29 15:08:30 +03:00
parent 7f62675665
commit 36fd8a1a08
14 changed files with 162 additions and 82 deletions
@@ -0,0 +1,12 @@
class A {
val b = B()
}
class B
fun B.invoke(i: Int) = i
fun foo(i: Int) = i
fun test(a: A?) {
a?.b(1) //should be no warning
foo(<!TYPE_MISMATCH!>a?.b(1)<!>) //no warning, only error
}
@@ -0,0 +1,57 @@
DescriptorResolver@0 {
<name not found> = JetTypeImpl@1['Int']
<name not found> = JetTypeImpl@2['Int']
<name not found> = MutableClassDescriptor$1@3
}
LazyJavaPackageFragmentProvider@4 {
packageFragments('<root>': FqName@5) = LazyJavaPackageFragment@6['<root>']
packageFragments('A': FqName@7) = null
packageFragments('B': FqName@8) = null
packageFragments('Int': FqName@9) = null
packageFragments('java': FqName@10) = LazyJavaPackageFragment@11['java']
packageFragments('java.lang': FqName@12) = LazyJavaPackageFragment@13['lang']
packageFragments('java.lang.A': FqName@14) = null
packageFragments('java.lang.B': FqName@15) = null
packageFragments('java.lang.Int': FqName@16) = null
packageFragments('kotlin': FqName@17) = null
packageFragments('kotlin.A': FqName@18) = null
packageFragments('kotlin.B': FqName@19) = null
packageFragments('kotlin.Int': FqName@20) = null
packageFragments('kotlin.io': FqName@21) = null
packageFragments('kotlin.jvm': FqName@22) = null
}
LazyJavaPackageFragment@6['<root>'] {
classes('B': Name@23) = null // through LazyPackageFragmentScopeForJavaPackage@24
classes('Int': Name@25) = null // through LazyPackageFragmentScopeForJavaPackage@24
classes('b': Name@26) = null // through LazyPackageFragmentScopeForJavaPackage@24
classes('foo': Name@27) = null // through LazyPackageFragmentScopeForJavaPackage@24
classes('invoke': Name@28) = null // through LazyPackageFragmentScopeForJavaPackage@24
deserializedPackageScope = Empty@29 // through LazyPackageFragmentScopeForJavaPackage@24
functions('B': Name@23) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@24
functions('b': Name@26) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@24
functions('foo': Name@27) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@24
functions('invoke': Name@28) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@24
memberIndex = computeMemberIndex$1@31 // through LazyPackageFragmentScopeForJavaPackage@24
}
LazyJavaPackageFragment@11['java'] {
classes('lang': Name@32) = null // through LazyPackageFragmentScopeForJavaPackage@33
deserializedPackageScope = Empty@29 // through LazyPackageFragmentScopeForJavaPackage@33
functions('lang': Name@34) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@33
memberIndex = computeMemberIndex$1@35 // through LazyPackageFragmentScopeForJavaPackage@33
}
LazyJavaPackageFragment@13['lang'] {
classes('B': Name@23) = null // through LazyPackageFragmentScopeForJavaPackage@36
classes('b': Name@26) = null // through LazyPackageFragmentScopeForJavaPackage@36
classes('foo': Name@27) = null // through LazyPackageFragmentScopeForJavaPackage@36
classes('invoke': Name@28) = null // through LazyPackageFragmentScopeForJavaPackage@36
deserializedPackageScope = Empty@29 // through LazyPackageFragmentScopeForJavaPackage@36
functions('B': Name@23) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@36
functions('b': Name@26) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@36
functions('foo': Name@27) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@36
functions('invoke': Name@28) = EmptyList@30[empty] // through LazyPackageFragmentScopeForJavaPackage@36
memberIndex = computeMemberIndex$1@37 // through LazyPackageFragmentScopeForJavaPackage@36
}
@@ -0,0 +1,20 @@
package
internal fun foo(/*0*/ i: kotlin.Int): kotlin.Int
internal fun test(/*0*/ a: A?): kotlin.Unit
internal fun B.invoke(/*0*/ i: kotlin.Int): kotlin.Int
internal final class A {
public constructor A()
internal final val b: B
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 B {
public constructor B()
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
}