Classes of the same package
Just like in Java, SmallJava classes should be able to refer to external classes in the same package without importing the package. However, this is not yet the case in the current implementation. For example, given the following two SmallJava files, they are not able to refer to each other without an explicit import, although they are in the same package:
// first file package my.pack; class A { B b; } // second file package my.pack; class B extends A {}
To solve this problem, we need to go back to our custom SmallJavaImportedNamespaceAwareLocalScopeProvider
that we implemented in section Default imports. The idea is to customize internalGetImportedNamespaceResolvers
so that when the context is a SmallJava program then we add an implicit import of the same package of the current SmallJava program, if the program has a package.
To do that, we create an ImportNormalizer
. We have already used ImportNormalizer
in section Default imports. This is the implementation...