Forbid usage of outer's generic parameter in nested class
#KT-1174 In Progress
This commit is contained in:
@@ -124,6 +124,11 @@ public class TypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolveTypeProjections(scope, ErrorUtils.createErrorType("No type").getConstructor(), type.getTypeArguments(), trace, checkBounds);
|
resolveTypeProjections(scope, ErrorUtils.createErrorType("No type").getConstructor(), type.getTypeArguments(), trace, checkBounds);
|
||||||
|
|
||||||
|
DeclarationDescriptor containing = typeParameterDescriptor.getContainingDeclaration();
|
||||||
|
if (containing instanceof ClassDescriptor) {
|
||||||
|
DescriptorResolver.checkHasOuterClassInstance(scope, trace, referenceExpression, (ClassDescriptor) containing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (classifierDescriptor instanceof ClassDescriptor) {
|
else if (classifierDescriptor instanceof ClassDescriptor) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptor;
|
ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptor;
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ class MyIterator<T>(val array : ReadOnlyArray<T>) : javaUtilIterator<T> {
|
|||||||
trait ReadOnlyArray<out T> : ISized, Iterable<T> {
|
trait ReadOnlyArray<out T> : ISized, Iterable<T> {
|
||||||
fun get(index : Int) : T
|
fun get(index : Int) : T
|
||||||
|
|
||||||
class Default {
|
|
||||||
fun check(v: Any) = v is T
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun iterator() : Iterator<T> = MyIterator<T>(this)
|
override fun iterator() : Iterator<T> = MyIterator<T>(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
class Box<T>() {
|
class Box<T>() {
|
||||||
open class Inner () {
|
open inner class Inner () {
|
||||||
fun isT(s : Any) = if(s is T) "OK" else "fail"
|
fun isT(s : Any) = if(s is T) "OK" else "fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
class Inner2() : Inner() {
|
inner class Inner2() : Inner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun inner() = Inner2()
|
fun inner() = Inner2()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MyIterable<T> : Iterable<T>
|
|||||||
{
|
{
|
||||||
override fun iterator(): Iterator<T> = MyIterator()
|
override fun iterator(): Iterator<T> = MyIterator()
|
||||||
|
|
||||||
class MyIterator : Iterator<T>
|
inner class MyIterator : Iterator<T>
|
||||||
{
|
{
|
||||||
override fun hasNext(): Boolean = false
|
override fun hasNext(): Boolean = false
|
||||||
override fun next(): T {
|
override fun next(): T {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class Outer<T> {
|
||||||
|
class Nested {
|
||||||
|
fun foo(t: <!INACCESSIBLE_OUTER_CLASS_EXPRESSION!>T<!>) = t
|
||||||
|
}
|
||||||
|
|
||||||
|
class Nested2<T> {
|
||||||
|
fun foo(t: T) = t
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class Inner {
|
||||||
|
fun foo(t: T) = t
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2459,6 +2459,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
|||||||
doTest("compiler/testData/diagnostics/tests/inner/nestedVsInnerAccessOuterMember.kt");
|
doTest("compiler/testData/diagnostics/tests/inner/nestedVsInnerAccessOuterMember.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outerGenericParam.kt")
|
||||||
|
public void testOuterGenericParam() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/inner/outerGenericParam.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("visibility.kt")
|
@TestMetadata("visibility.kt")
|
||||||
public void testVisibility() throws Exception {
|
public void testVisibility() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/inner/visibility.kt");
|
doTest("compiler/testData/diagnostics/tests/inner/visibility.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user