groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Papp (JIRA)" <>
Subject [jira] [Created] (GROOVY-8434) ClassCastException: Class cannot be cast to type-of-with's-delegate
Date Mon, 08 Jan 2018 01:17:00 GMT
Robert Papp created GROOVY-8434:

             Summary: ClassCastException: Class cannot be cast to type-of-with's-delegate
                 Key: GROOVY-8434
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 2.4.12
         Environment: Windows 10, Gradle 4.2.1
            Reporter: Robert Papp

I'm sorry for the hard repro, but I couldn't figure it out with a smaller one.
2. {{gradlew test}} (if you're lucky it runs and fails, otherwise don't fret there's an other

Test fails:

Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to org.gradle.api.reporting.ConfigurableReport
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2$_closure3.doCall(CheckStyleTask.groovy:95)
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2$
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2.doCall(CheckStyleTask.groovy:94)
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig.setupReports(CheckStyleTask.groovy:91)
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig.execute(CheckStyleTask.groovy:42)
	at net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig.execute(CheckStyleTask.groovy)
	at org.gradle.api.internal.tasks.DefaultTaskContainer.create(

Now, that's obviously not my error, because 1) it worked in the previous commit (when the
class wasn't an inner class) and 2) I'm using {{ast(groovy.transform.CompileStatic)}} to build.

Another way: {{gradlew groovyCompile}}, and then observe the build directory:
static def setupReports(CheckStyleTask task) {
	task.reports.with {
		def reportsDir = task.project.extensions.findByType(ReportingExtension).baseDir
		xml.with {
			enabled = true
			setDestination(new File(reportsDir, 'checkstyle.xml'))
compiles to
public Object doCall(Object it) {
                            boolean var2 = true;
                            Object var10001 = null;
File((File)ScriptBytecodeAdapter.castToType(this.reportsDir.get(), File.class), "checkstyle.html"));
                            Object var10000 = null;
Note: the first cast is wrong, the second one is using getDelegate properly.

This message was sent by Atlassian JIRA

View raw message