File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/main/kotlin/io/runescript/plugin/lang/psi/type/inference Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,14 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
56
56
}
57
57
}
58
58
o.parameterList?.parameterList?.forEach { it.accept(this ) }
59
+ val expectedParameterTypes = triggerType.parameterTypes
60
+ if (expectedParameterTypes != null ) {
61
+ val actualParametersType = o.parameterList?.parameterList
62
+ ?.map { it.localVariableExpression.type!! }
63
+ .fold()
64
+ val expectedParametersType = expectedParameterTypes.toList().fold()
65
+ checkTypeMismatch(o.scriptNameExpression, actualParametersType, expectedParametersType)
66
+ }
59
67
o.statementList.accept(this )
60
68
}
61
69
@@ -93,6 +101,16 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
93
101
return this
94
102
}
95
103
104
+ private fun Collection<RsType>?.fold (): RsType {
105
+ if (this == null ) {
106
+ return RsUnitType
107
+ }
108
+ if (size == 1 ) {
109
+ return first()
110
+ }
111
+ return RsTupleType (flatten())
112
+ }
113
+
96
114
private fun checkTypeMismatch (context : PsiElement , actualType : RsType ? , expectedType : RsType ? ) {
97
115
val unfoldedActualType = actualType.unfold() ? : RsErrorType
98
116
val unfoldedExpectedType = expectedType.unfold() ? : RsErrorType
You can’t perform that action at this time.
0 commit comments