diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java index 7e5283d293a..d1bc4a02f21 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java @@ -19,6 +19,8 @@ package org.jetbrains.jet.lang.psi.stubs.elements; import com.intellij.psi.tree.TokenSet; import org.jetbrains.jet.lang.psi.*; +import static org.jetbrains.jet.JetNodeTypes.SELF_TYPE; + public interface JetStubElementTypes { JetFileElementType FILE = new JetFileElementType(); @@ -117,7 +119,7 @@ public interface JetStubElementTypes { TokenSet DELEGATION_SPECIFIER_TYPES = TokenSet.create(DELEGATOR_BY, DELEGATOR_SUPER_CALL, DELEGATOR_SUPER_CLASS, THIS_CALL); - TokenSet TYPE_ELEMENT_TYPES = TokenSet.create(USER_TYPE, NULLABLE_TYPE, FUNCTION_TYPE, DYNAMIC_TYPE); + TokenSet TYPE_ELEMENT_TYPES = TokenSet.create(USER_TYPE, NULLABLE_TYPE, FUNCTION_TYPE, DYNAMIC_TYPE, SELF_TYPE); TokenSet INSIDE_DIRECTIVE_EXPRESSIONS = TokenSet.create(REFERENCE_EXPRESSION, DOT_QUALIFIED_EXPRESSION); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.kt index bff32bab41b..c06d3944c3e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.kt @@ -35,7 +35,6 @@ import org.jetbrains.jet.context.LazinessToken import org.jetbrains.jet.lang.resolve.lazy.LazyEntity import org.jetbrains.jet.lang.resolve.lazy.ForceResolveUtil import org.jetbrains.jet.utils.addToStdlib.firstIsInstanceOrNull -import org.jetbrains.jet.lang.diagnostics.Errors public class TypeResolver( private val annotationResolver: AnnotationResolver, @@ -230,6 +229,10 @@ public class TypeResolver( } } + override fun visitSelfType(type: JetSelfType) { + c.trace.report(UNSUPPORTED.on(type, "Self-types are not supported")) + } + override fun visitJetElement(element: JetElement) { c.trace.report(UNSUPPORTED.on(element, "Self-types are not supported yet")) } diff --git a/compiler/testData/diagnostics/tests/SelfTypesUnsupported.kt b/compiler/testData/diagnostics/tests/SelfTypesUnsupported.kt new file mode 100644 index 00000000000..43c2f651488 --- /dev/null +++ b/compiler/testData/diagnostics/tests/SelfTypesUnsupported.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(f: This) {} + +trait CThis>> { + val x: This + val y: This? +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/SelfTypesUnsupported.txt b/compiler/testData/diagnostics/tests/SelfTypesUnsupported.txt new file mode 100644 index 00000000000..8252ab0e333 --- /dev/null +++ b/compiler/testData/diagnostics/tests/SelfTypesUnsupported.txt @@ -0,0 +1,11 @@ +package + +internal fun foo(/*0*/ f: [ERROR : This]): kotlin.Unit + +internal trait C> { + internal abstract val x: [ERROR : This] + internal abstract val y: [ERROR : This]? + 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 +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 00a7824d7d0..dc17b4d80c9 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -442,6 +442,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("SelfTypesUnsupported.kt") + public void testSelfTypesUnsupported() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/SelfTypesUnsupported.kt"); + doTest(fileName); + } + @TestMetadata("ShiftFunctionTypes.kt") public void testShiftFunctionTypes() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/ShiftFunctionTypes.kt");