From e3d2b013dafee051ff27cee3b4d432a34aa822f2 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 18 Jul 2012 14:44:52 +0400 Subject: [PATCH] added tests for specific type inference errors --- .../inference/conflictingSubstitutions.kt | 19 +++++++++++++++++++ .../inference/noInformationForParameter.kt | 14 ++++++++++++++ .../inference/typeConstructorMismatch.kt | 13 +++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/inference/conflictingSubstitutions.kt create mode 100644 compiler/testData/diagnostics/tests/inference/noInformationForParameter.kt create mode 100644 compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt diff --git a/compiler/testData/diagnostics/tests/inference/conflictingSubstitutions.kt b/compiler/testData/diagnostics/tests/inference/conflictingSubstitutions.kt new file mode 100644 index 00000000000..1c2d8a25779 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/conflictingSubstitutions.kt @@ -0,0 +1,19 @@ +package conflictingSubstitutions +//+JDK + +import java.util.* + +fun elemAndList(r: R, t: List): R = r +fun R.elemAndListWithReceiver(r: R, t: List): R = r + +fun test() { + val s = elemAndList(11, list("72")) + + val u = 11.elemAndListWithReceiver(4, list("7")) +} + +fun list(value: T) : ArrayList { + val list = ArrayList() + list.add(value) + return list +} diff --git a/compiler/testData/diagnostics/tests/inference/noInformationForParameter.kt b/compiler/testData/diagnostics/tests/inference/noInformationForParameter.kt new file mode 100644 index 00000000000..af53ae4ba5e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/noInformationForParameter.kt @@ -0,0 +1,14 @@ +package noInformationForParameter +//+JDK + +import java.util.* + +fun test() { + val n = newList() + + val n1 : List = newList() +} + +fun newList() : ArrayList { + return ArrayList() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt b/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt new file mode 100644 index 00000000000..1f672624e48 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt @@ -0,0 +1,13 @@ +package typeConstructorMismatch +//+JDK + +import java.util.* + +fun test(set: Set) { + elemAndList("2", set) + + "".elemAndListWithReceiver("", set) +} + +fun elemAndList(r: R, t: List): R = r +fun R.elemAndListWithReceiver(r: R, t: List): R = r