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

Gradle 7.2 Version Catalog Plugins gives an IDE error "'val Project.libs: LibrariesForLibs' can't be called in this context by implicit receiver. Use the explicit one if necessary" #18107

Closed
EdricChan03 opened this issue Aug 24, 2021 · 3 comments
Assignees

Comments

@EdricChan03
Copy link

EdricChan03 commented Aug 24, 2021

Expected Behavior

Plugin libraries defined in a Version Catalog file should be accessible in the plugins block with no issues

Current Behavior

Plugin libraries are accessible in the plugins block (and the buildscript builds fine), but a red squiggly line can be seen on the libs part in the IDE with the error:

Screenshot of IDE hovercard on libs

(Text version:)

'val Project.libs: LibrariesForLibs' can't be called in this context by implicit receiver. Use the explicit one if necessary

This Google IssueTracker comment about the same issue points out that:

That error comes from the Kotlin plugin. I think Kotlin wants you to refer to libs more explicitly using syntax like this@<ImplicitReceiver>.libs.

However, this syntax doesn't appear to work no matter what I've tried.

Using either version of the classes that the IDE suggests:

Suggested classes

plugins {
    alias(this@<kotlin.reflect.jvm.internal.impl.resolve.scopes.receivers.ImplicitReceiver>.libs.plugins.buildProperties)
    // OR
    alias(this@<org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver>.libs.plugins.buildProperties)
}

Gives another error:

Function invocation 'this@<kotlin.reflect.jvm.internal.impl.resolve.scopes.receivers.ImplicitReceiver>(...)' expected
Function invocation 'this@<org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver>(...)' expected

Context

Trying to update defined build plugins to use the new Version Catalogs API for easier version management

Steps to Reproduce

gradle/lib.versions.toml

[plugins]
buildProperties = "com.novoda.build-properties:0.4.1"

app/build.gradle.kts

plugins {
    alias(libs.plugins.buildProperties)
}

(GitHub project)

Your Environment

IDE

Android Studio Bumblebee | 2021.1.1 Canary 9
Build #AI-211.7628.21.2111.7653804, built on August 19, 2021
Runtime version: 11.0.10+0-b96-7249189 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true, documentation.show.toolbar=true
Non-Bundled Plugins: org.toml.lang (0.2.153.4056-211), org.jetbrains.kotlin (211-1.5.21-release-328-AS7442.40)

Build scan

URL: https://gradle.com/s/ostfhaxrfyjna

@dsvensson
Copy link

Issue is tracked in IDEA here, https://youtrack.jetbrains.com/issue/KTIJ-19369

@mlopatkin mlopatkin self-assigned this Aug 24, 2021
@mlopatkin
Copy link
Member

Looks like an IDEA/AS bug per the comment above.

@mlopatkin mlopatkin added closed:android An issue with the Android Gradle Plugin or Android Studio and removed to-triage labels Aug 24, 2021
@TWiStErRob
Copy link
Contributor

Duplicate of #22797

@eskatos eskatos added in:kotlin-dsl closed:duplicate Duplicated or superseeded by another issue in:dependency-version-catalog and removed closed:android An issue with the Android Gradle Plugin or Android Studio labels Jan 17, 2023
@eskatos eskatos closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants