Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception when running ArrayPrimitive on star-projected arrays #2181

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

dimsuz
Copy link
Contributor

@dimsuz dimsuz commented Dec 16, 2019

Closes #2176

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for investigating and providing a fix so quickly.
This PR looks fine. Please see my comment regarding the validity of the test snippet code.

@@ -73,6 +78,11 @@ class ArrayPrimitiveSpec : Spek({
assertThat(subject.compileAndLint(code)).isEmpty()
}

it("is a star-projected array") {
val code = "fun returningFunction(): Array<*> { return emptyArray() }"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snippet is not a valid Kotlin code.
We have an additional CI check that verifies, whether the test code is valid.

io.gitlab.arturbosch.detekt.test.KotlinScriptException: Given Kotlin code is invalid.

Caused by: javax.script.ScriptException: Error: error: type inference failed: Not enough information to infer parameter T in inline fun <reified T> emptyArray(): Array<T>
Please specify it explicitly.

fun returningFunction(): Array<*> { return emptyArray() }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very cool! Fixed it with emptyArray<Any>().

@codecov-io
Copy link

Codecov Report

Merging #2181 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2181   +/-   ##
=========================================
  Coverage     80.59%   80.59%           
- Complexity     2028     2029    +1     
=========================================
  Files           338      338           
  Lines          5850     5850           
  Branches       1066     1066           
=========================================
  Hits           4715     4715           
  Misses          564      564           
  Partials        571      571
Impacted Files Coverage Δ Complexity Δ
...urbosch/detekt/rules/performance/ArrayPrimitive.kt 86.2% <0%> (ø) 11 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f41ea5...51fddc0. Read the comment docs.

@schalkms schalkms merged commit e25a2c1 into detekt:master Dec 18, 2019
@dimsuz dimsuz deleted the fix-2176 branch December 18, 2019 23:34
@arturbosch arturbosch added this to the 1.3.0 milestone Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running "ArrayPrimitive" rule on "Array<*>" causes detekt to throw exception
4 participants