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

Cannot compile instanceof check when CompileStatic is used #1016

Open
renatoathaydes opened this issue Aug 27, 2019 · 0 comments

Comments

@renatoathaydes
Copy link

commented Aug 27, 2019

Issue description

When using @CompileStatic on a spec, assertions like a instanceof T do not compile.

How to reproduce

Try to compile the following spec:

import groovy.transform.CompileStatic
import spock.lang.Specification

@CompileStatic
class Broken2 extends Specification {
    def "test"() {
        when:
        def x = getSomething()
        then:
        x instanceof String
    }

    def getSomething() { 'hello' }
}

Output:

./gradlew compileTestGroovy

> Task :compileTestGroovy FAILED
startup failed:
/Users/renato/programming/projects/spock-tests/src/test/groovy/Broken2.groovy: 10: [Static type checking] - Cannot find matching method java.lang.Object#isInstance(java.lang.Object). Please check if the declared type is correct and if the method exists.
 @ line 10, column 9.
           x instanceof String

When only the Groovy compiler is used, it produces the correct bytecode as far as I can tell.

Additional Environment information

Dependencies:

dependencies {
    compile 'org.spockframework:spock-core:1.3-groovy-2.5'
}

gradle --version

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_181 (Azul Systems, Inc. 25.181-b02)
OS:           Mac OS X 10.14.6 x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.