[ https://issues.apache.org/jira/browse/GROOVY-11224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-11224: ------------------------------- Description: This is a follow-on of GROOVY-8254 for groovysh. We may end up closing this issue with no change but a few aspects seem worth considering: * Following the stricter interpretation by the compiler, adding a second (duplicate) import via the groovysh now causes a compiler "evaluate" error. Do we want to be more lenient in the repl context and in fact treat the import "list" like a simple name to class map and override old entries. This would be more repl-like in style. * If I define a class and then do an import, then the class is ignored with no error. Perhaps we want an error in that case. {code} groovy:000> class Date{} ===> true groovy:000> :show classes Classes: class Date ===> [class Date] groovy:000> import java.sql.Date ===> java.sql.Date groovy:000> println Date class java.sql.Date {code} was: {code:title=foo/Foo.groovy} package foo class Foo {} {code} {code:title=test/test.groovy} package test import foo.Foo as Bar class Bar {} def regular = new Bar() def anonymous = new Bar() {} println regular.class // class test.Bar println anonymous.class.superclass // class foo.Foo {code} Either both of the invocations should use alias or both of them should use class defined in the same file. > Reconsider name duplication for groovysh > ---------------------------------------- > > Key: GROOVY-11224 > URL: https://issues.apache.org/jira/browse/GROOVY-11224 > Project: Groovy > Issue Type: Bug > Reporter: Paul King > Priority: Major > Labels: breaking, breaking_change > > This is a follow-on of GROOVY-8254 for groovysh. We may end up closing this > issue with no change but a few aspects seem worth considering: > * Following the stricter interpretation by the compiler, adding a second > (duplicate) import via the groovysh now causes a compiler "evaluate" error. > Do we want to be more lenient in the repl context and in fact treat the > import "list" like a simple name to class map and override old entries. This > would be more repl-like in style. > * If I define a class and then do an import, then the class is ignored with > no error. Perhaps we want an error in that case. > {code} > groovy:000> class Date{} > ===> true > groovy:000> :show classes > Classes: > class Date > ===> [class Date] > groovy:000> import java.sql.Date > ===> java.sql.Date > groovy:000> println Date > class java.sql.Date > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)