GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Include interferes with imports of enum instances · Issue #296 · kscripting/kscript

Include interferes with imports of enum instances #296

New issue
Copy link
New issue
Copy link
Open
Open
Include interferes with imports of enum instances#296
Copy link

Description

@reitzig
reitzig
opened on Dec 12, 2020
Issue body actions

Consider this file repro.kts:

import Repro.Foo.Bar

enum class Foo {
    Bar
}

println(Bar)

This runs and prints Bar -- all is well.
Now, add an include directive (file can be empty):

@file:Include("shared.kt")

import Repro.Foo.Bar

enum class Foo {
    Bar
}

println(Bar)

And we get an error:

OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
/tmp/tmp16041171746066319857.tmp/scriptlet.803d758a4961398c.kts:1:8: error: unresolved reference: Repro
import Repro.Foo.Bar
       ^
/tmp/tmp16041171746066319857.tmp/scriptlet.803d758a4961398c.kts:11:9: error: unresolved reference: Bar
println(Bar)
        ^

Reproduces with and without content in shared.kt, and also with comment include directive.
Also reproduces with other nested constructs such as inner classes:

sealed class Foo {
    object Bar: Foo()
}

Does not reproduce with IDEA, which runs the files just fine (and created the import statement for me, in face). Therefore, I suspect a bug in kscript.


Real-life example: link


Version : v3.0.2
Kotlin : 1.4.21-release-351
Java : JRE 14.0.2+12)

Reproduces with JRE 11 as well.

Activity

  1. reitzig commented on Dec 13, 2020

    @reitzig
    reitzig
    on Dec 13, 2020
    Author
    More actions

    Ah. The problem is the file name of the aggregate file, isn't it? kscript would either have to use the original file names, or rewrite the imports. 🤔

  2. holgerbrandl commented on Dec 20, 2020

    @holgerbrandl
    holgerbrandl
    on Dec 20, 2020
    Collaborator
    More actions

    It indeed assumed to the included file to be in the same package. It partially rewrites the imports to show up on top of the merged script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.