Skip to content

Commit ff5b397

Browse files
authored
Merge pull request #812 from Kotlin/interpretation-error-fix
[Compiler plugin] silently abort interpretation in case of invariant errors
2 parents 74cd917 + 1f17c53 commit ff5b397

File tree

1 file changed

+19
-13
lines changed
  • plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin

1 file changed

+19
-13
lines changed

plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/interpret.kt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,38 @@ fun <T> KotlinTypeFacade.interpret(
9090
val defaultArguments = processor.expectedArguments.filter { it.defaultValue is Present }.map { it.name }.toSet()
9191
val actualArgsMap = refinedArguments.associateBy { it.name.identifier }.toSortedMap()
9292
val conflictingKeys = additionalArguments.keys intersect actualArgsMap.keys
93-
if (conflictingKeys.isNotEmpty() && isTest) {
94-
interpretationFrameworkError("Conflicting keys: $conflictingKeys")
93+
if (conflictingKeys.isNotEmpty()) {
94+
if (isTest) {
95+
interpretationFrameworkError("Conflicting keys: $conflictingKeys")
96+
}
97+
return null
9598
}
9699
val expectedArgsMap = processor.expectedArguments
97100
.filterNot { it.name.startsWith("typeArg") }
98101
.associateBy { it.name }.toSortedMap().minus(additionalArguments.keys)
99102

100103
val unexpectedArguments = expectedArgsMap.keys - defaultArguments != actualArgsMap.keys - defaultArguments
101-
if (unexpectedArguments && isTest) {
102-
val message = buildString {
103-
appendLine("ERROR: Different set of arguments")
104-
appendLine("Implementation class: $processor")
105-
appendLine("Not found in actual: ${expectedArgsMap.keys - actualArgsMap.keys}")
106-
val diff = actualArgsMap.keys - expectedArgsMap.keys
107-
appendLine("Passed, but not expected: ${diff}")
108-
appendLine("add arguments to an interpeter:")
109-
appendLine(diff.map { actualArgsMap[it] })
104+
if (unexpectedArguments) {
105+
if (isTest) {
106+
val message = buildString {
107+
appendLine("ERROR: Different set of arguments")
108+
appendLine("Implementation class: $processor")
109+
appendLine("Not found in actual: ${expectedArgsMap.keys - actualArgsMap.keys}")
110+
val diff = actualArgsMap.keys - expectedArgsMap.keys
111+
appendLine("Passed, but not expected: ${diff}")
112+
appendLine("add arguments to an interpeter:")
113+
appendLine(diff.map { actualArgsMap[it] })
114+
}
115+
interpretationFrameworkError(message)
110116
}
111-
interpretationFrameworkError(message)
117+
return null
112118
}
113119

114120
val arguments = mutableMapOf<String, Interpreter.Success<Any?>>()
115121
arguments += additionalArguments
116122
val interpretationResults = refinedArguments.refinedArguments.mapNotNull {
117123
val name = it.name.identifier
118-
val expectedArgument = expectedArgsMap[name]!!
124+
val expectedArgument = expectedArgsMap[name] ?: error("$processor $name")
119125
val expectedReturnType = expectedArgument.klass
120126
val value: Interpreter.Success<Any?>? = when (expectedArgument.lens) {
121127
is Interpreter.Value -> {

0 commit comments

Comments
 (0)